testrail-runs.t 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. use strict;
  2. use warnings;
  3. use FindBin;
  4. use lib $FindBin::Bin.'/../bin';
  5. require 'testrail-runs';
  6. use lib $FindBin::Bin.'/lib';
  7. use Test::LWP::UserAgent::TestRailMock;
  8. use Test::More 'tests' => 13;
  9. use Capture::Tiny qw{capture_merged};
  10. #check status filters
  11. my @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject };
  12. my ($out,$code) = TestRail::Bin::Runs::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
  13. is($code, 0, "Exit code OK looking for runs with passes");
  14. chomp $out;
  15. like($out,qr/^OtherOtherSuite\nTestingSuite\nFinalRun\nlockRun\nClosedRun$/,"Gets run correctly looking for passes");
  16. #check LIFO sort
  17. @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject --lifo };
  18. ($out,$code) = TestRail::Bin::Runs::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
  19. is($code, 0, "Exit code OK looking for runs with passes");
  20. chomp $out;
  21. like($out,qr/^lockRun\nClosedRun\nTestingSuite\nFinalRun\nOtherOtherSuite$/,"LIFO sort works");
  22. #check milesort
  23. @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject --milesort };
  24. ($out,$code) = TestRail::Bin::Runs::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
  25. is($code, 0, "Exit code OK looking for runs with passes");
  26. chomp $out;
  27. like($out,qr/^TestingSuite\nFinalRun\nlockRun\nClosedRun\nOtherOtherSuite$/,"milesort works");
  28. #check status filters
  29. @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject --status passed};
  30. ($out,$code) = TestRail::Bin::Runs::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
  31. is($code, 255, "Exit code OK looking for runs with passes, which should fail to return results");
  32. chomp $out;
  33. like($out,qr/no runs found/i,"Gets no runs correctly looking for passes");
  34. #TODO check configs for real next time
  35. @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject --config testConfig --config eee};
  36. ($out,$code) = TestRail::Bin::Runs::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
  37. is($code, 255, "Exit code OK looking for runs with passes");
  38. chomp $out;
  39. like($out,qr/no runs found/i,"Gets no run correctly when filtering by unassigned config");
  40. #Verify no-match returns non path
  41. @args = qw{--help};
  42. $0 = $FindBin::Bin.'/../bin/testrail-runs';
  43. ($out,(undef,$code)) = capture_merged {TestRail::Bin::Runs::run('args' => \@args)};
  44. is($code, 0, "Exit code OK asking for help");
  45. like($out,qr/encoding of arguments/i,"Help output OK");
  46. #Make sure that the binary itself processes args correctly
  47. $out = `$^X $0 --help`;
  48. like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");