X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=t%2FGruntmaster-Data.t;h=e9d20ac8cf7938b27d05fdd150a3c276eb0fd9c1;hb=dcd72991e2d01ab1465afa494c0b6b4a1fd36e25;hp=51a3cef22bfbcb1e386ece4b2d132bac32fb154f;hpb=bbf8209c979ab3d89e93e13117dd4b9f639dba9c;p=gruntmaster-data.git diff --git a/t/Gruntmaster-Data.t b/t/Gruntmaster-Data.t index 51a3cef..e9d20ac 100644 --- a/t/Gruntmaster-Data.t +++ b/t/Gruntmaster-Data.t @@ -1,18 +1,38 @@ -# Before 'make install' is performed this script should be runnable with -# 'make test'. After 'make install' it should work as 'perl Gruntmaster-Data.t' +#!/usr/bin/perl -w +use v5.14; -######################### +use Test::More tests => 13; -# change 'tests => 1' to 'tests => last_test_to_print'; +BEGIN { use_ok('Gruntmaster::Data') }; -use strict; -use warnings; +my $db = Gruntmaster::Data->connect('dbi:SQLite:dbname=:memory:'); +$db->deploy; -use Test::More tests => 1; -BEGIN { use_ok('Gruntmaster::Data') }; +$db->users->create({id => 'MGV'}); +$db->contests->create({id => 'fc', start => 10, stop => 20, name => 'Finished contest', owner => 'MGV'}); +$db->contests->create({id => 'rc', start => 20, stop => 30, name => 'Running contest', owner => 'MGV'}); +$db->contests->create({id => 'pc', start => 30, stop => 40, name => 'Pending contest', owner => 'MGV'}); + +ok $db->contest('pc')->is_pending(25), 'is_pending'; +ok !$db->contest('rc')->is_pending(25), '!is_pending'; +ok $db->contest('fc')->is_finished(25), 'is_finished'; +ok !$db->contest('rc')->is_finished(25), '!is_finished'; +ok $db->contest('rc')->is_running(25), 'is_running'; + +$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}); + +ok !$db->problem('pb')->is_private(25), '!is_private'; +$db->problem('pb')->update({private => 1}); +ok $db->problem('pb')->is_private(25), 'is_private (explicit)'; +$db->problem('pb')->update({private => 0}); -######################### +$db->contest_problems->create({contest => 'pc', problem => 'pb'}); +ok $db->problem('pb')->is_private(25), 'is_private (implicit)'; +ok $db->problem('pb')->is_in_archive(25), 'is_in_archive'; -# Insert your test code below, the Test::More module is use()ed here so read -# its man page ( perldoc Test::More ) for help writing this test script. +$db->contest_problems->create({contest => 'rc', problem => 'pb'}); +ok $db->problem('pb')->is_private(25), 'is_private (also implicit)'; +ok !$db->problem('pb')->is_in_archive(25), '!is_in_archive'; +$db->contest_problems->find('rc', 'pb')->delete; +ok $db->problem('pb')->is_in_archive(25), 'is_in_archive (again)';