|
|
@@ -13,6 +13,7 @@ use TestRail::Utils::Lock;
|
|
|
use Test::LWP::UserAgent::TestRailMock;
|
|
|
use Sys::Hostname qw{hostname};
|
|
|
use File::Basename qw{basename};
|
|
|
+use Capture::Tiny qw{capture};
|
|
|
|
|
|
my $opts = {
|
|
|
'project' => 'TestProject',
|
|
|
@@ -31,7 +32,8 @@ my $tr = new TestRail::API($apiurl,$login,$pw,undef,1);
|
|
|
$tr->{'debug'} = 0;
|
|
|
$tr->{'browser'} = Test::LWP::UserAgent::TestRailMock::lockMockStep0();
|
|
|
|
|
|
-my $ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr);
|
|
|
+my $ret;
|
|
|
+capture { $ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr) };
|
|
|
is($ret,0,"Verify that no tests are locked in match mode, as they all are in a subdir, and recurse is off");
|
|
|
delete $opts->{'no-recurse'};
|
|
|
|
|
|
@@ -47,14 +49,15 @@ $ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr);
|
|
|
is(basename( $ret->{'path'} ), 'lockmetoo.test' , "Verify that the highest priority test that exists in the tree is chosen");
|
|
|
$tr->{'browser'} = Test::LWP::UserAgent::TestRailMock::lockMockStep3();
|
|
|
|
|
|
-$ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr);
|
|
|
+capture { $ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr) };
|
|
|
is($ret,0,"Verify that no tests are locked, as they either are of the wrong type or do not exist in the match tree");
|
|
|
$tr->{'browser'} = Test::LWP::UserAgent::TestRailMock::lockMockStep4();
|
|
|
|
|
|
#Simulate lock collision
|
|
|
my ($lockStatusID) = $tr->statusNamesToIds('locked');
|
|
|
my ($project,$plan,$run) = TestRail::Utils::getRunInformation($tr,$opts);
|
|
|
-is(TestRail::Utils::Lock::lockTest($tr->getTestByName($run->{'id'},'lockme.test'),$lockStatusID,'race.bannon',$tr),0,"False returned when race condition is simulated");
|
|
|
+capture { $ret = TestRail::Utils::Lock::lockTest($tr->getTestByName($run->{'id'},'lockme.test'),$lockStatusID,'race.bannon',$tr) };
|
|
|
+is($ret ,0,"False returned when race condition is simulated");
|
|
|
$tr->{'browser'} = Test::LWP::UserAgent::TestRailMock::lockMockStep5();
|
|
|
|
|
|
#Test with a second set of options, verify that no-match and type filtering works
|
|
|
@@ -69,7 +72,7 @@ $ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr);
|
|
|
is($ret->{'path'},'dontlockme_alsonothere.test',"Test which is not here but the other type is locked when omitting match");
|
|
|
$tr->{'browser'} = Test::LWP::UserAgent::TestRailMock::lockMockStep7();
|
|
|
|
|
|
-$ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr);
|
|
|
+capture { $ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr) };
|
|
|
is($ret,0,"No tests are locked, as they are not the right type");
|
|
|
|
|
|
#Make sure we only grab retest/untested
|
|
|
@@ -78,5 +81,5 @@ $ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr);
|
|
|
is($ret->{'path'},'dontlockme_nothere.test',"Wrong type test which is not here gets locked after we remove all restrictions");
|
|
|
$tr->{'browser'} = Test::LWP::UserAgent::TestRailMock::lockMockStep8();
|
|
|
|
|
|
-$ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr);
|
|
|
+capture { $ret = TestRail::Utils::Lock::pickAndLockTest($opts,$tr) };
|
|
|
is($ret,0,"No tests are locked, as none are untested or retest");
|