1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License
15 # Tests for the model of Opportunity
18 import opportunity_model
20 redef class OpportunityDB
23 execute
("DROP TABLE people;")
24 execute
("DROP TABLE meetups;")
25 execute
("DROP TABLE answers;")
26 execute
("DROP TABLE part_answers;")
27 execute
("DROP INDEX answers_clean;")
28 execute
("DROP INDEX ans_clean;")
29 execute
("DROP INDEX ppl_clean;")
36 var db
= new OpportunityDB.open
("opportunity")
46 db
= new OpportunityDB.open
("opportunity")
48 var hj
= new People("Jack", "Handsome")
50 var m
= new Meetup("Awaken the warrior", "2024/05/28", "Vault of the Warrior", 0)
53 var vh
= new People("Hunter", "Vault")
55 var ll
= new People("", "Lilith")
57 var y
= new Answer("Yes")
61 var n
= new Answer("No")
65 var h
= new Answer("I have no choice, I'm a hostage")
89 print db
.find_meetup_by_id
(m
.id
) or else "null"
91 for i
in m
.participants
(db
) do
92 print
"Answers for {i.to_s.trim}"
94 for k
,v
in i
.answers
do
95 print
"{k.to_s.trim} => {v.to_s.trim}"