Make problem value NOT NULL
[gruntmaster-data.git] / t / Gruntmaster-Data.t
CommitLineData
1ce4e27c
MG
1#!/usr/bin/perl -w
2use v5.14;
bbf8209c 3
acb202c6 4use Test::More tests => 13;
bbf8209c 5
bbf8209c 6BEGIN { use_ok('Gruntmaster::Data') };
acb202c6
MG
7
8my $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
16ok $db->contest('pc')->is_pending(25), 'is_pending';
17ok !$db->contest('rc')->is_pending(25), '!is_pending';
18ok $db->contest('fc')->is_finished(25), 'is_finished';
19ok !$db->contest('rc')->is_finished(25), '!is_finished';
20ok $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
24ok !$db->problem('pb')->is_private(25), '!is_private';
25$db->problem('pb')->update({private => 1});
26ok $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'});
30ok $db->problem('pb')->is_private(25), 'is_private (implicit)';
31ok $db->problem('pb')->is_in_archive(25), 'is_in_archive';
32
33$db->contest_problems->create({contest => 'rc', problem => 'pb'});
34ok $db->problem('pb')->is_private(25), 'is_private (also implicit)';
35ok !$db->problem('pb')->is_in_archive(25), '!is_in_archive';
36
37$db->contest_problems->find('rc', 'pb')->delete;
38ok $db->problem('pb')->is_in_archive(25), 'is_in_archive (again)';
This page took 0.012114 seconds and 4 git commands to generate.