]>
iEval git - gruntmaster-data.git/blob - t/tools.t
4 use Test
::More skip_all
=> 'These tests are badly outdated and broken';
6 use Test
::More tests
=> 13;
7 use File
::Temp qw
/tempdir/;
10 use Gruntmaster
::Data
;
12 my $perl = $Config{perlpath
} . $Config{_exe
};
13 my $dir = tempdir CLEANUP
=> 1;
14 $ENV{GRUNTMASTER_DSN
} = "dbi:SQLite:dbname=$dir/testdb";
19 local $db = Gruntmaster
::Data
->connect($ENV{GRUNTMASTER_DSN
});
23 withdb
{ $db->deploy };
27 open $pipe, "|$perl gruntmaster-contest add ct";
37 subtest
'gruntmaster-contest add' => sub {
39 my $ct = $db->contest('ct');
40 ok
$ct, 'contest exists';
41 is
$ct->name, 'My cool contest', 'contest name';
42 is
$ct->owner->id, 'MGV', 'contest owner';
43 is
$ct->start, 1388534400, 'contest start';
44 is
$ct->stop, 1388534400 + 5 * 60 * 60, 'contest stop';
48 is
`$perl gruntmaster-contest get ct owner`, "MGV\n", 'gruntmaster-contest get';
49 system $perl, 'gruntmaster-contest', 'set', 'ct', 'owner', 'nobody';
50 withdb
{ is
$db->contest('ct')->owner->id, 'nobody', 'gruntmaster-contest set' };
52 withdb
{ $db->contests->create({id
=> 'dummy', name
=> 'Dummy contest', owner
=> 'MGV', start
=> 0, stop
=> 1}) };
53 my @list = sort `$perl gruntmaster-contest list`;
55 my @list2 = withdb
{ map { $_->id } $db->contests->all };
56 is_deeply \
@list, [ sort @list2 ], 'gruntmaster-contest list';
58 system $perl, 'gruntmaster-contest', 'rm', 'dummy';
59 withdb
{ ok
!$db->contest('dummy'), 'gruntmaster-contest rm' };
61 open $pipe, "|$perl gruntmaster-problem add pb";
84 subtest
'gruntmaster-problem add' => sub {
86 my $pb = $db->problem('pb');
87 ok
$pb, 'problem exists';
88 is
$pb->name, 'Test problem', 'name';
89 is
$pb->author, 'Marius Gavrilescu', 'author';
90 is
$pb->writer, 'Smaranda Ciubotaru', 'statement writer';
91 is
$pb->owner->id, 'MGV', 'owner';
92 is
$pb->level, 'easy', 'level';
93 is
$pb->generator, 'Undef', 'generator';
94 is
$pb->runner, 'File', 'runner';
95 is
$pb->judge, 'Absolute', 'judge';
96 is
$pb->testcnt, 3, 'test count';
97 is
$pb->timeout, 1, 'time limit';
98 is
$pb->olimit, 100, 'output limit';
99 ok
$db->contest_problems->find('ct', 'pb'), 'is in contest';
103 is
`$perl gruntmaster-problem get pb author`, "Marius Gavrilescu\n", 'gruntmaster-problem get';
104 system $perl, 'gruntmaster-problem', 'set', 'pb', 'owner', 'nobody';
105 withdb
{ is
$db->problem('pb')->owner->id, 'nobody', 'gruntmaster-problem set' };
107 withdb
{ $db->problems->create({id
=> 'dummy', name
=> 'Dummy', generator
=> 'Undef', runner
=> 'File', judge
=> 'Absolute', level
=> 'beginner', value
=> 100, owner
=> 'MGV', statement
=> '...', testcnt
=> 1, timeout
=> 1}) };
109 @list = sort `$perl gruntmaster-problem list`;
111 @list2 = withdb
{ map { $_->id } $db->problems->all };
112 is_deeply \
@list, [ sort @list2 ], 'gruntmaster-problem list';
114 system $perl, 'gruntmaster-problem', 'rm', 'dummy';
115 withdb
{ ok
!$db->problem('dummy'), 'gruntmaster-problem rm' };
117 withdb
{ $db->jobs->create({id
=> 1, date
=> 1, extension
=> '.ext', format
=> 'CPP', problem
=> 'pb', source
=> '...', owner
=> 'MGV'}) };
119 is
`$perl gruntmaster-job get 1 format`, "CPP\n", 'gruntmaster-job get';
120 system $perl, 'gruntmaster-job', 'set', 1, 'format', 'PERL';
121 withdb
{ is
$db->job(1)->format, 'PERL', 'gruntmaster-job set' };
123 system $perl, 'gruntmaster-job', 'rm', 1;
124 withdb
{ ok
!$db->job(1), 'gruntmaster-job rm' };
This page took 0.069194 seconds and 4 git commands to generate.