]> iEval git - gruntmaster-data.git/blobdiff - t/tools.t
Do not crash in t/tools.t if postgres is not running
[gruntmaster-data.git] / t / tools.t
index ab16348a974da5986ff0abf38d440bf7cc93bf51..6a08457cf960816b2a3450fb08b6170e3fa8fbcb 100644 (file)
--- a/t/tools.t
+++ b/t/tools.t
@@ -8,9 +8,11 @@ use App::Cmd::Tester;
 
 BEGIN {
        eval {
-               Gruntmaster::Data::init 'dbi:Pg:dbname=gmtest'; 1;
+               dbinit 'dbi:Pg:dbname=gmtest'; 1;
        } or plan skip_all => 'Cannot connect to test database. Create it by running make_test_db.sh before running this test. '. "Error: $@";
-       plan tests => 28;
+       no warnings 'redefine';
+       *Gruntmaster::App::dbinit = sub {}; # Prevent reinit in Gruntmaster::App->run
+       plan tests => 30;
 }
 
 sub fakein {
@@ -78,6 +80,11 @@ EOF
 
 ta [qw/-p add pb/];
 
+{
+       my $out = ta([qw/-p show pb/])->output;
+       like $out, qr/Value \(points\): 250/, 'gm -p show pb contains Value'
+}
+
 subtest 'gruntmaster-problem add' => sub {
        plan tests => 10;
        my $pb = problem_entry 'pb';
@@ -96,6 +103,8 @@ subtest 'gruntmaster-problem add' => sub {
 ta [qw/-p get pb author/], 'Marius Gavrilescu';
 ta [qw/-p set pb owner nobody/];
 ta [qw/-p get pb owner/], 'nobody';
+ta [qw/-p set --file pb statement README/];
+like problem_entry('pb')->{statement}, qr/Gruntmaster-Data/, 'gm -p set --file pb statement README';
 ta [qw/-p list/], join "\n", sort qw/arc pca rca fca prv pb/;
 ta [qw/-p rm pb/];
 ok !defined problem_entry ('pb'), 'gm -p rm pb';
This page took 0.011119 seconds and 4 git commands to generate.