|
|
@@ -9,9 +9,11 @@ require 'testrail-results';
|
|
|
use lib $FindBin::Bin.'/lib';
|
|
|
use Test::LWP::UserAgent::TestRailMock;
|
|
|
|
|
|
-use Test::More 'tests' => 26;
|
|
|
+use Test::More 'tests' => 31;
|
|
|
use Capture::Tiny qw{capture_merged};
|
|
|
use List::MoreUtils qw{uniq};
|
|
|
+use Test::Fatal;
|
|
|
+use File::Temp qw{tempdir};
|
|
|
|
|
|
no warnings qw{redefine once};
|
|
|
*TestRail::API::getTests = sub {
|
|
|
@@ -61,7 +63,7 @@ use warnings;
|
|
|
my @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake t/fake.test };
|
|
|
my ($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
|
|
|
is($code, 0, "Exit code OK looking for results of fake.test");
|
|
|
-like($out,qr/fake\.test was present in 515 runs/,"Gets correct # of runs with test inside it");
|
|
|
+like($out,qr/fake\.test was present in 509 runs/,"Gets correct # of runs with test inside it");
|
|
|
|
|
|
#check project filters
|
|
|
@args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject t/fake.test };
|
|
|
@@ -74,7 +76,7 @@ like($out,qr/fake\.test was present in 10 runs/,"Gets correct # of runs with tes
|
|
|
push(@args,'mah dubz plan', 't/fake.test');
|
|
|
($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
|
|
|
is($code, 0, "Exit code OK looking for results of fake.test");
|
|
|
-like($out,qr/fake\.test was present in 259 runs/,"Gets correct # of runs with test inside it when filtering by plan name");
|
|
|
+like($out,qr/fake\.test was present in 253 runs/,"Gets correct # of runs with test inside it when filtering by plan name");
|
|
|
|
|
|
#check run filters
|
|
|
@args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --run FinalRun t/fake.test};
|
|
|
@@ -86,7 +88,7 @@ like($out,qr/fake\.test was present in 1 runs/,"Gets correct # of runs with test
|
|
|
@args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --grep zippy t/fake.test};
|
|
|
($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
|
|
|
is($code, 0, "Exit code OK looking for results of fake.test");
|
|
|
-like($out,qr/Retest: 515/,"Gets correct # & status of runs with test inside it when grepping");
|
|
|
+like($out,qr/Retest: 509/,"Gets correct # & status of runs with test inside it when grepping");
|
|
|
unlike($out,qr/Failed: 515/,"Gets correct # & status of runs with test inside it when grepping");
|
|
|
|
|
|
@args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --json t/fake.test };
|
|
|
@@ -94,6 +96,28 @@ unlike($out,qr/Failed: 515/,"Gets correct # & status of runs with test inside it
|
|
|
is($code, 0, "Exit code OK looking for results of fake.test in json mode");
|
|
|
like($out,qr/num_runs/,"Gets # of runs with test inside it in json mode");
|
|
|
|
|
|
+#For making the test data to test the caching
|
|
|
+#open(my $fh, '>', "t/data/faketest_cache.json");
|
|
|
+#print $fh $out;
|
|
|
+#close($fh);
|
|
|
+
|
|
|
+#Check caching
|
|
|
+@args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --json --cachefile t/data/faketest_cache.json t/fake.test };
|
|
|
+($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
|
|
|
+is($code, 0, "Exit code OK looking for results of fake.test in json mode");
|
|
|
+chomp $out;
|
|
|
+is($out,"{}","Caching mode works");
|
|
|
+
|
|
|
+#check pertest mode
|
|
|
+@args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --json --perfile bogus.dir t/fake.test };
|
|
|
+like( exception { TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args) }, qr/no such dir/i, "Bad pertest dir throws");
|
|
|
+my $dir = tempdir( CLEANUP => 1);
|
|
|
+@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --json --perfile}, $dir, 't/fake.test');
|
|
|
+($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
|
|
|
+is($code, 0, "Exit code OK looking for results of fake.test in json mode");
|
|
|
+chomp $out;
|
|
|
+ok(-f "$dir/fake.test.json","pertest write works");
|
|
|
+
|
|
|
#check defect & version filters
|
|
|
{
|
|
|
no warnings qw{redefine once};
|
|
|
@@ -111,17 +135,22 @@ like($out,qr/num_runs/,"Gets # of runs with test inside it in json mode");
|
|
|
|
|
|
}
|
|
|
|
|
|
-#For making the test data to test the caching
|
|
|
-#open(my $fh, '>', "t/data/faketest_cache.json");
|
|
|
-#print $fh $out;
|
|
|
-#close($fh);
|
|
|
+#check fast mode
|
|
|
+{
|
|
|
+ no warnings qw{redefine once};
|
|
|
+ local *TestRail::API::getTestByName = sub { return { 'id' => '666', 'run_id' => 123, 'elapsed' => 1 } };
|
|
|
+ local *TestRail::API::getRunResults = sub {
|
|
|
+ return [
|
|
|
+ { 'test_id' => 666, 'status_id' => 2, 'defects' => ['YOLO-666'], version => 666},
|
|
|
+ { 'test_id' => 666, 'defects' => undef, 'status_id' => 1, 'version' => 333}
|
|
|
+ ];
|
|
|
+ };
|
|
|
+ @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --defect YOLO-666 --fast t/skip.test };
|
|
|
+ ($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
|
|
|
+ is($code, 0, "Exit code OK looking for defects of skip.test -- fastmode");
|
|
|
+ like($out,qr/YOLO-666/,"Gets # of runs with defects inside it -- fastmode");
|
|
|
|
|
|
-#Check caching
|
|
|
-@args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --json --cachefile t/data/faketest_cache.json t/fake.test };
|
|
|
-($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
|
|
|
-is($code, 0, "Exit code OK looking for results of fake.test in json mode");
|
|
|
-chomp $out;
|
|
|
-is($out,"{}","Caching mode works");
|
|
|
+}
|
|
|
|
|
|
#Check time parser
|
|
|
is(TestRail::Bin::Results::_elapsed2secs('1s'),1,"elapsed2secs works : seconds");
|