server_dead.t 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #Test behavior if the server magically disappears
  2. #Basically the policy is no death, return false when this happens.
  3. use strict;
  4. use warnings;
  5. use TestRail::API;
  6. use Test::More 'tests' => 52;
  7. use Test::Fatal;
  8. use Class::Inspector;
  9. use Test::LWP::UserAgent;
  10. use HTTP::Response;
  11. use IO::Capture::Stderr;
  12. my $capture_out = IO::Capture::Stderr->new();
  13. $capture_out->start;
  14. my $tr = TestRail::API->new('http://hokum.bogus','bogus','bogus',1);
  15. $tr->{'browser'} = Test::LWP::UserAgent->new();
  16. $tr->{'browser'}->map_response(qr/.*/, HTTP::Response->new('500', 'ERROR', ['Content-Type' => 'text/plain'], ''));
  17. is( $tr->_doRequest('badMethod'), -500,"Bad Request fails");
  18. is($tr->apiurl,'http://hokum.bogus',"APIURL OK");
  19. is($tr->debug,1,"DEBUG OK");
  20. is($tr->createCase(1,'whee',1),-500,'createCase returns error');
  21. is($tr->createMilestone(1,'whee'),-500,'createMilestone returns error');
  22. is($tr->createPlan(1,'whee'),-500,'createPlan returns error');
  23. is($tr->createProject('zippy'),-500,'createProject returns error');
  24. is($tr->createRun(1,1,'whee'),-500,'createRun returns error');
  25. is($tr->createSection(1,1,'whee'),-500,'createSection returns error');
  26. is($tr->createTestResults(1,1),-500,'createTestResults returns error');
  27. is($tr->createTestSuite(1,'zugzug'),-500,'createTestSuite returns error');
  28. is($tr->deleteCase(1),-500,'deleteCase returns error');
  29. is($tr->deleteMilestone(1),-500,'deleteMilestone returns error');
  30. is($tr->deletePlan(1),-500,'deletePlan returns error');
  31. is($tr->deleteProject(1),-500,'deleteProject returns error');
  32. is($tr->deleteRun(1),-500,'deleteRun returns error');
  33. is($tr->deleteSection(1),-500,'deleteSection returns error');
  34. is($tr->deleteTestSuite(1),-500,'deleteTestSuite returns error');
  35. is($tr->getCaseByID(1),-500,'getCaseByID returns error');
  36. is($tr->getCaseByName(1,1,1,'hug'),-500,'getCaseByName returns error');
  37. is($tr->getCaseTypeByName('zap'),-500,'getCaseTypeByName returns error');
  38. is($tr->getCaseTypes(),-500,'getCaseTypes returns error');
  39. is($tr->getCases(1,2,3),-500,'getCases returns error');
  40. is($tr->getMilestoneByID(1,1),-500,'getMilestoneByID returns error');
  41. is($tr->getMilestoneByName(1,'hug'),-500,'getMilestoneByName returns error');
  42. is($tr->getMilestones(1),-500,'getMilestones returns error');
  43. is($tr->getPlanByID(1),-500,'getPlanByID returns error');
  44. is($tr->getPlanByName(1,'nugs'),-500,'getPlanByName returns error');
  45. is($tr->getPlans(1),-500,'getPlans returns error');
  46. is($tr->getPossibleTestStatuses(),-500,'getPossibleTestStatuses returns error');
  47. is($tr->getProjectByID(1),-500,'getProjectByID returns error');
  48. is($tr->getProjectByName('fake'),-500,'getProjectByName returns error');
  49. is($tr->getProjects(),-500,'getProjects returns error');
  50. is($tr->getRunByID(1),-500,'getRunByID returns error');
  51. is($tr->getRunByName(1,'zoom'),-500,'getRunByName returns error');
  52. is($tr->getRuns(1),-500,'getRuns returns error');
  53. is($tr->getSectionByID(1),-500,'getSectionByID returns error');
  54. is($tr->getSectionByName(1,1,'zip'),-500,'getSectionByName returns error');
  55. is($tr->getSections(1,1),-500,'getSections returns error');
  56. is($tr->getTestByID(1),-500,'getTestByID returns error');
  57. is($tr->getTestByName(1,'poo'),-500,'getTestByName returns error');
  58. is($tr->getTestResultFields(),-500,'getTestResultFields returns error');
  59. is($tr->getTestResults(1,1),-500,'getTestResults returns error');
  60. is($tr->getTestSuiteByID(1),-500,'getTestSuiteByID returns error');
  61. is($tr->getTestSuiteByName(1,'zap'),-500,'getTestSuiteByName returns error');
  62. is($tr->getTestSuites(1),-500,'getTestSuites returns error');
  63. is($tr->getTests(1),-500,'getTests returns error');
  64. is($tr->getUserByEmail('tickle'),0,'getUserByEmail returns error');
  65. is($tr->getUserByID(1),0,'getUserByID returns error');
  66. is($tr->getUserByName('zap'),0,'getUserByName returns error');
  67. is($tr->getUsers(),-500,'getUsers returns error');
  68. is($tr->getConfigurations(1),-500,'getConfigurations returns error');
  69. $capture_out->stop();