]>
iEval git - gruntmaster-data.git/blob - t/tools.t
4 use Test
::More tests
=> 13;
5 use File
::Temp qw
/tempdir/;
9 my $dir = tempdir CLEANUP
=> 1;
10 $ENV{GRUNTMASTER_DSN
} = "dbi:SQLite:dbname=$dir/testdb";
15 local $db = Gruntmaster
::Data
->connect($ENV{GRUNTMASTER_DSN
});
19 withdb
{ $db->deploy };
23 open $pipe, '|./gruntmaster-contest add ct';
33 subtest
'gruntmaster-contest add' => sub {
35 my $ct = $db->contest('ct');
36 ok
$ct, 'contest exists';
37 is
$ct->name, 'My cool contest', 'contest name';
38 is
$ct->owner->id, 'MGV', 'contest owner';
39 is
$ct->start, 1388534400, 'contest start';
40 is
$ct->stop, 1388534400 + 5 * 60 * 60, 'contest stop';
44 is
`./gruntmaster-contest get ct owner`, "MGV\n", 'gruntmaster-contest get';
45 system './gruntmaster-contest', 'set', 'ct', 'owner', 'nobody';
46 withdb
{ is
$db->contest('ct')->owner->id, 'nobody', 'gruntmaster-contest set' };
48 withdb
{ $db->contests->create({id
=> 'dummy', name
=> 'Dummy contest', owner
=> 'MGV', start
=> 0, stop
=> 1}) };
49 my @list = sort `./gruntmaster-contest list`;
51 my @list2 = withdb
{ map { $_->id } $db->contests->all };
52 is_deeply \
@list, [ sort @list2 ], 'gruntmaster-contest list';
54 system './gruntmaster-contest', 'rm', 'dummy';
55 withdb
{ ok
!$db->contest('dummy'), 'gruntmaster-contest rm' };
57 open $pipe, '|./gruntmaster-problem add pb';
80 subtest
'gruntmaster-problem add' => sub {
82 my $pb = $db->problem('pb');
83 ok
$pb, 'problem exists';
84 is
$pb->name, 'Test problem', 'name';
85 is
$pb->author, 'Marius Gavrilescu', 'author';
86 is
$pb->writer, 'Smaranda Ciubotaru', 'statement writer';
87 is
$pb->owner->id, 'MGV', 'owner';
88 is
$pb->level, 'easy', 'level';
89 is
$pb->generator, 'Undef', 'generator';
90 is
$pb->runner, 'File', 'runner';
91 is
$pb->judge, 'Absolute', 'judge';
92 is
$pb->testcnt, 3, 'test count';
93 is
$pb->timeout, 1, 'time limit';
94 is
$pb->olimit, 100, 'output limit';
95 ok
$db->contest_problems->find('ct', 'pb'), 'is in contest';
99 is
`./gruntmaster-problem get pb author`, "Marius Gavrilescu\n", 'gruntmaster-problem get';
100 system './gruntmaster-problem set pb owner nobody';
101 withdb
{ is
$db->problem('pb')->owner->id, 'nobody', 'gruntmaster-problem set' };
103 withdb
{ $db->problems->create({id
=> 'dummy', name
=> 'Dummy', generator
=> 'Undef', runner
=> 'File', judge
=> 'Absolute', level
=> 'beginner', owner
=> 'MGV', statement
=> '...', testcnt
=> 1, timeout
=> 1}) };
105 @list = sort `./gruntmaster-problem list`;
107 @list2 = withdb
{ map { $_->id } $db->problems->all };
108 is_deeply \
@list, [ sort @list2 ], 'gruntmaster-problem list';
110 system './gruntmaster-problem', 'rm', 'dummy';
111 withdb
{ ok
!$db->problem('dummy'), 'gruntmaster-problem rm' };
113 withdb
{ $db->jobs->create({id
=> 1, date
=> 1, extension
=> '.ext', format
=> 'CPP', problem
=> 'pb', source
=> '...', owner
=> 'MGV'}) };
115 is
`./gruntmaster-job get 1 format`, "CPP\n", 'gruntmaster-job get';
116 system './gruntmaster-job', 'set', 1, 'format', 'PERL';
117 withdb
{ is
$db->job(1)->format, 'PERL', 'gruntmaster-job set' };
119 system './gruntmaster-job', 'rm', 1;
120 withdb
{ ok
!$db->job(1), 'gruntmaster-job rm' };
This page took 0.057243 seconds and 4 git commands to generate.