TestRail-API-mockOnly.t 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. use strict;
  2. use warnings;
  3. #Test things we can only mock, because the API doesn't support them.
  4. use Test::More 'tests' => 9;
  5. use TestRail::API;
  6. use Test::LWP::UserAgent::TestRailMock;
  7. use Scalar::Util qw{reftype};
  8. my $browser = $Test::LWP::UserAgent::TestRailMock::mockObject;
  9. my $tr = TestRail::API->new('http://hokum.bogus','fake','fake',1);
  10. $tr->{'browser'} = $browser;
  11. $tr->{'debug'} = 0;
  12. #Have to mock anything requiring configs
  13. my $project = $tr->getProjectByName('TestProject');
  14. my $plan = $tr->getPlanByName($project->{'id'},'HooHaaPlan');
  15. my $runs = $tr->getChildRuns($plan);
  16. is(reftype($runs),'ARRAY',"getChildRuns returns array");
  17. is(scalar(@$runs),4,"getChildRuns with multi-configs in the same group returns correct # of runs");
  18. my $summary = $tr->getPlanSummary($plan->{'id'});
  19. is($summary->{'plan'},1094,"Plan ID makes it through in summary method");
  20. is($summary->{'totals'}->{'untested'},4,"Gets total number of tests correctly");
  21. is($summary->{'percentages'}->{'untested'},'100.00%',"Gets total percentages correctly");
  22. #Also have to mock anything requiring test result fields (all are custom)
  23. my $projResType = $tr->getTestResultFieldByName('step_results');
  24. is($projResType->{'id'},6,"Can get result field by name");
  25. $projResType = $tr->getTestResultFieldByName('step_results',$project->{'id'});
  26. is($projResType->{'id'},6,"Can get result field by name, AND filter by project ID");
  27. $projResType = $tr->getTestResultFieldByName('moo_results');
  28. is($projResType,0,"Bad name returns no result field");
  29. $projResType = $tr->getTestResultFieldByName('step_results',66669);
  30. is($projResType,-3,"Bad project returns no result field");