--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+# Tests for the model of Opportunity
+module db_tests
+
+import opportunity_model
+
+redef class OpportunityDB
+
+ fun wipe do
+ execute("DROP TABLE people;")
+ execute("DROP TABLE meetups;")
+ execute("DROP TABLE answers;")
+ execute("DROP TABLE part_answers;")
+ execute("DROP INDEX answers_clean;")
+ execute("DROP INDEX ans_clean;")
+ execute("DROP INDEX ppl_clean;")
+ end
+
+end
+
+print "Opening DB"
+
+var db = new OpportunityDB.open("opportunity")
+
+print "DB opened"
+
+db.wipe
+
+print "Wiped"
+
+db.close
+
+db = new OpportunityDB.open("opportunity")
+
+var hj = new People("Jack", "Handsome")
+
+var m = new Meetup("Awaken the warrior", "2024/05/28", "Vault of the Warrior")
+assert m.commit(db)
+
+var vh = new People("Hunter", "Vault")
+
+var ll = new People("", "Lilith")
+
+var y = new Answer("Yes")
+y.meetup = m
+y.commit(db)
+
+var n = new Answer("No")
+n.meetup = m
+n.commit(db)
+
+var h = new Answer("I have no choice, I'm a hostage")
+h.meetup = m
+h.commit(db)
+
+hj.answer(y) = true
+hj.answer(n) = false
+hj.answer(h) = false
+
+vh.answer(y) = true
+vh.answer(n) = false
+vh.answer(h) = false
+
+ll.answer(y) = true
+ll.answer(n) = false
+ll.answer(h) = true
+
+hj.commit db
+vh.commit db
+ll.commit db
+
+assert hj.commit(db)
+assert vh.commit(db)
+assert ll.commit(db)
+
+print db.find_meetup_by_id(m.id) or else "null"
+
+for i in m.participants(db) do
+ print "Answers for {i.to_s.trim}"
+ i.load_answers(db, m)
+ for k,v in i.answers do
+ print "{k.to_s.trim} => {v.to_s.trim}"
+ end
+end
+
+db.close
--- /dev/null
+Opening DB
+DB opened
+Wiped
+Event : Awaken the warrior
+When : 2024/05/28
+Where : Vault of the Warrior
+Answers for Handsome Jack
+Yes => true
+No => false
+I have no choice, I'm a hostage => false
+Answers for Vault Hunter
+Yes => true
+No => false
+I have no choice, I'm a hostage => false
+Answers for Lilith
+Yes => true
+No => false
+I have no choice, I'm a hostage => true