testrail-lock.t 1.1 KB

12345678910111213141516171819202122232425262728
  1. use strict;
  2. use warnings;
  3. use Test::More "tests" => 5;
  4. use FindBin;
  5. use Capture::Tiny qw{capture_merged};
  6. use lib $FindBin::Bin.'/../bin';
  7. require 'testrail-lock';
  8. use lib $FindBin::Bin.'/lib';
  9. use Test::LWP::UserAgent::TestRailMock;
  10. my @args = qw{--help};
  11. $0 = $FindBin::Bin.'/../bin/testrail-lock';
  12. my ($out,(undef,$code)) = capture_merged {TestRail::Bin::Lock::run('args' => \@args)};
  13. is($code, 0, "Exit code OK asking for help");
  14. like($out,qr/encoding of arguments/i,"Help output OK");
  15. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j },"CRUSH ALL HUMANS", '-r', "SEND T-1000 INFILTRATION UNITS BACK IN TIME", qw{--lockname locked});
  16. ($out,(undef,$code)) = capture_merged { TestRail::Bin::Lock::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args) };
  17. is($code, 255, "Exit code bad when no case could be locked");
  18. chomp $out;
  19. like($out,qr/failed to lock case/i,"Output is as expected");
  20. #Make sure that the binary itself processes args correctly
  21. $out = `$^X $0 --help`;
  22. like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");