testrail-runs.t 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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' => 12;
  9. use IO::CaptureOutput qw{capture};
  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. (undef,$code) = capture {TestRail::Bin::Runs::run('args' => \@args)} \$out, \$out;
  44. is($code, 0, "Exit code OK asking for help");
  45. like($out,qr/encoding of arguments/i,"Help output OK");