server_dead.t 3.8 KB

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