Make problem value NOT NULL
[gruntmaster-data.git] / t / Gruntmaster-Data.t
1 #!/usr/bin/perl -w
2 use v5.14;
3
4 use Test::More tests => 13;
5
6 BEGIN { use_ok('Gruntmaster::Data') };
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
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});
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)';
This page took 0.02777 seconds and 4 git commands to generate.