testrail-runs.t 2.2 KB

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