]>
Commit | Line | Data |
---|---|---|
1ce4e27c MG |
1 | #!/usr/bin/perl -w |
2 | use v5.14; | |
bbf8209c | 3 | |
acb202c6 | 4 | use Test::More tests => 13; |
bbf8209c | 5 | |
bbf8209c | 6 | BEGIN { use_ok('Gruntmaster::Data') }; |
acb202c6 MG |
7 | |
8 | my $db = Gruntmaster::Data->connect('dbi:SQLite:dbname=:memory:'); | |
9 | $db->deploy; | |
10 | ||
11 | $db->users->create({id => 'MGV'}); | |
12 | $db->contests->create({id => 'fc', start => 10, stop => 20, name => 'Finished contest', owner => 'MGV'}); | |
13 | $db->contests->create({id => 'rc', start => 20, stop => 30, name => 'Running contest', owner => 'MGV'}); | |
14 | $db->contests->create({id => 'pc', start => 30, stop => 40, name => 'Pending contest', owner => 'MGV'}); | |
15 | ||
16 | ok $db->contest('pc')->is_pending(25), 'is_pending'; | |
17 | ok !$db->contest('rc')->is_pending(25), '!is_pending'; | |
18 | ok $db->contest('fc')->is_finished(25), 'is_finished'; | |
19 | ok !$db->contest('rc')->is_finished(25), '!is_finished'; | |
20 | ok $db->contest('rc')->is_running(25), 'is_running'; | |
21 | ||
aaa9eb7d | 22 | $db->problems->create({id => 'pb', name => 'Problem', generator => 'Undef', runner => 'File', judge => 'Absolute', level => 'beginner', value => 100, owner => 'MGV', statement => '...', testcnt => 1, timeout => 1, private => 0}); |
acb202c6 MG |
23 | |
24 | ok !$db->problem('pb')->is_private(25), '!is_private'; | |
25 | $db->problem('pb')->update({private => 1}); | |
26 | ok $db->problem('pb')->is_private(25), 'is_private (explicit)'; | |
27 | $db->problem('pb')->update({private => 0}); | |
28 | ||
29 | $db->contest_problems->create({contest => 'pc', problem => 'pb'}); | |
30 | ok $db->problem('pb')->is_private(25), 'is_private (implicit)'; | |
31 | ok $db->problem('pb')->is_in_archive(25), 'is_in_archive'; | |
32 | ||
33 | $db->contest_problems->create({contest => 'rc', problem => 'pb'}); | |
34 | ok $db->problem('pb')->is_private(25), 'is_private (also implicit)'; | |
35 | ok !$db->problem('pb')->is_in_archive(25), '!is_in_archive'; | |
36 | ||
37 | $db->contest_problems->find('rc', 'pb')->delete; | |
38 | ok $db->problem('pb')->is_in_archive(25), 'is_in_archive (again)'; |