]>
iEval git - gruntmaster-data.git/blob - t/tools.t
4 use Test
::More tests
=> 13;
5 use File
::Temp qw
/tempdir/;
10 my $perl = $Config{perlpath
} . $Config{_exe
};
11 my $dir = tempdir CLEANUP
=> 1;
12 $ENV{GRUNTMASTER_DSN
} = "dbi:SQLite:dbname=$dir/testdb";
17 local $db = Gruntmaster
::Data
->connect($ENV{GRUNTMASTER_DSN
});
21 withdb
{ $db->deploy };
25 open $pipe, "|$perl gruntmaster-contest add ct";
35 subtest
'gruntmaster-contest add' => sub {
37 my $ct = $db->contest('ct');
38 ok
$ct, 'contest exists';
39 is
$ct->name, 'My cool contest', 'contest name';
40 is
$ct->owner->id, 'MGV', 'contest owner';
41 is
$ct->start, 1388534400, 'contest start';
42 is
$ct->stop, 1388534400 + 5 * 60 * 60, 'contest stop';
46 is
`$perl gruntmaster-contest get ct owner`, "MGV\n", 'gruntmaster-contest get';
47 system $perl, 'gruntmaster-contest', 'set', 'ct', 'owner', 'nobody';
48 withdb
{ is
$db->contest('ct')->owner->id, 'nobody', 'gruntmaster-contest set' };
50 withdb
{ $db->contests->create({id
=> 'dummy', name
=> 'Dummy contest', owner
=> 'MGV', start
=> 0, stop
=> 1}) };
51 my @list = sort `$perl gruntmaster-contest list`;
53 my @list2 = withdb
{ map { $_->id } $db->contests->all };
54 is_deeply \
@list, [ sort @list2 ], 'gruntmaster-contest list';
56 system $perl, 'gruntmaster-contest', 'rm', 'dummy';
57 withdb
{ ok
!$db->contest('dummy'), 'gruntmaster-contest rm' };
59 open $pipe, "|$perl gruntmaster-problem add pb";
82 subtest
'gruntmaster-problem add' => sub {
84 my $pb = $db->problem('pb');
85 ok
$pb, 'problem exists';
86 is
$pb->name, 'Test problem', 'name';
87 is
$pb->author, 'Marius Gavrilescu', 'author';
88 is
$pb->writer, 'Smaranda Ciubotaru', 'statement writer';
89 is
$pb->owner->id, 'MGV', 'owner';
90 is
$pb->level, 'easy', 'level';
91 is
$pb->generator, 'Undef', 'generator';
92 is
$pb->runner, 'File', 'runner';
93 is
$pb->judge, 'Absolute', 'judge';
94 is
$pb->testcnt, 3, 'test count';
95 is
$pb->timeout, 1, 'time limit';
96 is
$pb->olimit, 100, 'output limit';
97 ok
$db->contest_problems->find('ct', 'pb'), 'is in contest';
101 is
`$perl gruntmaster-problem get pb author`, "Marius Gavrilescu\n", 'gruntmaster-problem get';
102 system $perl, 'gruntmaster-problem', 'set', 'pb', 'owner', 'nobody';
103 withdb
{ is
$db->problem('pb')->owner->id, 'nobody', 'gruntmaster-problem set' };
105 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}) };
107 @list = sort `$perl gruntmaster-problem list`;
109 @list2 = withdb
{ map { $_->id } $db->problems->all };
110 is_deeply \
@list, [ sort @list2 ], 'gruntmaster-problem list';
112 system $perl, 'gruntmaster-problem', 'rm', 'dummy';
113 withdb
{ ok
!$db->problem('dummy'), 'gruntmaster-problem rm' };
115 withdb
{ $db->jobs->create({id
=> 1, date
=> 1, extension
=> '.ext', format
=> 'CPP', problem
=> 'pb', source
=> '...', owner
=> 'MGV'}) };
117 is
`$perl gruntmaster-job get 1 format`, "CPP\n", 'gruntmaster-job get';
118 system $perl, 'gruntmaster-job', 'set', 1, 'format', 'PERL';
119 withdb
{ is
$db->job(1)->format, 'PERL', 'gruntmaster-job set' };
121 system $perl, 'gruntmaster-job', 'rm', 1;
122 withdb
{ ok
!$db->job(1), 'gruntmaster-job rm' };
This page took 0.064339 seconds and 4 git commands to generate.