arg_types.t 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. use strict;
  2. use warnings;
  3. use TestRail::API;
  4. use Test::More 'tests' => 143;
  5. use Test::Fatal;
  6. use Class::Inspector;
  7. use Test::LWP::UserAgent;
  8. use HTTP::Response;
  9. my $tr = TestRail::API->new('http://hokum.bogus','bogus','bogus',undef,1);
  10. $tr->{'browser'} = Test::LWP::UserAgent->new();
  11. $tr->{'browser'}->map_response(qr/.*/, HTTP::Response->new('500', 'ERROR', ['Content-Type' => 'text/plain'], ''));
  12. #No-arg functions
  13. is( exception {$tr->getCaseTypes() },undef,'getCaseTypes returns no error when no arguments are passed');
  14. is( exception {$tr->getPossibleTestStatuses() },undef,'getPossibleTestStatuses returns no error when no arguments are passed');
  15. is( exception {$tr->getProjects() },undef,'getProjects returns no error when no arguments are passed');
  16. is( exception {$tr->getTestResultFields() },undef,'getTestResultFields returns no error when no arguments are passed');
  17. is( exception {$tr->getUsers() },undef,'getUsers returns no error when no arguments are passed');
  18. isnt( exception {$tr->createCase() },undef,'createCase returns error when no arguments are passed');
  19. isnt( exception {$tr->createMilestone() },undef,'createMilestone returns error when no arguments are passed');
  20. isnt( exception {$tr->createPlan() },undef,'createPlan returns error when no arguments are passed');
  21. isnt( exception {$tr->createProject() },undef,'createProject returns error when no arguments are passed');
  22. isnt( exception {$tr->createRun() },undef,'createRun returns error when no arguments are passed');
  23. isnt( exception {$tr->createSection() },undef,'createSection returns error when no arguments are passed');
  24. isnt( exception {$tr->createTestResults() },undef,'createTestResults returns error when no arguments are passed');
  25. isnt( exception {$tr->createTestSuite() },undef,'createTestSuite returns error when no arguments are passed');
  26. isnt( exception {$tr->deleteCase() },undef,'deleteCase returns error when no arguments are passed');
  27. isnt( exception {$tr->deleteMilestone() },undef,'deleteMilestone returns error when no arguments are passed');
  28. isnt( exception {$tr->deletePlan() },undef,'deletePlan returns error when no arguments are passed');
  29. isnt( exception {$tr->deleteProject() },undef,'deleteProject returns error when no arguments are passed');
  30. isnt( exception {$tr->deleteRun() },undef,'deleteRun returns error when no arguments are passed');
  31. isnt( exception {$tr->deleteSection() },undef,'deleteSection returns error when no arguments are passed');
  32. isnt( exception {$tr->deleteTestSuite() },undef,'deleteTestSuite returns error when no arguments are passed');
  33. isnt( exception {$tr->getCaseByID() },undef,'getCaseByID returns error when no arguments are passed');
  34. isnt( exception {$tr->getCaseByName() },undef,'getCaseByName returns error when no arguments are passed');
  35. isnt( exception {$tr->getCaseTypeByName() },undef,'getCaseTypeByName returns error when no arguments are passed');
  36. isnt( exception {$tr->getCases() },undef,'getCases returns error when no arguments are passed');
  37. isnt( exception {$tr->getMilestoneByID() },undef,'getMilestoneByID returns error when no arguments are passed');
  38. isnt( exception {$tr->getMilestoneByName() },undef,'getMilestoneByName returns error when no arguments are passed');
  39. isnt( exception {$tr->getPlanByID() },undef,'getPlanByID returns error when no arguments are passed');
  40. isnt( exception {$tr->getPlanByName() },undef,'getPlanByName returns error when no arguments are passed');
  41. isnt( exception {$tr->getProjectByID() },undef,'getProjectByID returns error when no arguments are passed');
  42. isnt( exception {$tr->getProjectByName() },undef,'getProjectByName returns error when no arguments are passed');
  43. isnt( exception {$tr->getRunByID() },undef,'getRunByID returns error when no arguments are passed');
  44. isnt( exception {$tr->getRunByName() },undef,'getRunByName returns error when no arguments are passed');
  45. isnt( exception {$tr->getSectionByID() },undef,'getSectionByID returns error when no arguments are passed');
  46. isnt( exception {$tr->getSectionByName() },undef,'getSectionByName returns error when no arguments are passed');
  47. isnt( exception {$tr->sectionNamesToIds() },undef,'sectionNamesToIds returns error when no arguments are passed');
  48. isnt( exception {$tr->getTestByID() },undef,'getTestByID returns error when no arguments are passed');
  49. isnt( exception {$tr->getTestByName() },undef,'getTestByName returns error when no arguments are passed');
  50. isnt( exception {$tr->getTestResults() },undef,'getTestResults returns error when no arguments are passed');
  51. isnt( exception {$tr->getTestResultFieldByName() },undef,'getTestResultFieldByName returns error when no arguments are passed');
  52. isnt( exception {$tr->getTestSuiteByID() },undef,'getTestSuiteByID returns error when no arguments are passed');
  53. isnt( exception {$tr->getTestSuiteByName() },undef,'getTestSuiteByName returns error when no arguments are passed');
  54. isnt( exception {$tr->getUserByEmail() },0,'getUserByEmail returns error when no arguments are passed');
  55. isnt( exception {$tr->getUserByID() },0,'getUserByID returns error when no arguments are passed');
  56. isnt( exception {$tr->getUserByName() },0,'getUserByName returns error when no arguments are passed');
  57. isnt( exception {$tr->getTests() },undef,'getTests returns error when no arguments are passed');
  58. isnt( exception {$tr->getTestSuites() },undef,'getTestSuites returns error when no arguments are passed');
  59. isnt( exception {$tr->getSections() },undef,'getSections returns error when no arguments are passed');
  60. isnt( exception {$tr->getRuns() },undef,'getRuns returns error when no arguments are passed');
  61. isnt( exception {$tr->getRunsPaginated() },undef,'getRunsPaginated returns error when no arguments are passed');
  62. isnt( exception {$tr->getPlans() },undef,'getPlans returns error when no arguments are passed');
  63. isnt( exception {$tr->getPlansPaginated() },undef,'getPlansPaginated returns error when no arguments are passed');
  64. isnt( exception {$tr->getMilestones() },undef,'getMilestones returns error when no arguments are passed');
  65. isnt( exception {$tr->getConfigurationGroups() },undef,'getConfigurations returns error when no arguments are passed');
  66. isnt( exception {$tr->getConfigurations() },undef,'getConfigurationGroups returns error when no arguments are passed');
  67. isnt( exception {$tr->getChildRuns() },undef,'getChildRuns returns error when no arguments are passed');
  68. isnt( exception {$tr->getChildRunByName() },undef,'getChildRunByName returns error when no arguments are passed');
  69. isnt( exception {$tr->createRunInPlan() },undef,'createRunInPlan returns error when no arguments are passed');
  70. isnt( exception {$tr->translateConfigNamesToIds()}, undef,'translateConfigNamesToIds returns error when no arguments are passed');
  71. isnt( exception {$tr->userNamesToIds()}, undef,'userNamesToIds returns error when no arguments are passed');
  72. isnt( exception {$tr->statusNamesToIds()}, undef,'statusNamesToIds returns error when no arguments are passed');
  73. isnt( exception {$tr->getRunSummary()}, undef,'getRunSummary returns error when no arguments are passed');
  74. isnt( exception {$tr->getPlanSummary()}, undef,'getPlanSummary returns error when no arguments are passed');
  75. isnt( exception {$tr->bulkAddResults()}, undef,'bulkAddResults returns error when no arguments are passed');
  76. #1-arg functions
  77. is(exception {$tr->deleteCase(1)}, undef,'deleteCase returns no error when int arg passed');
  78. is(exception {$tr->deleteMilestone(1)}, undef,'deleteMilestone returns no error when int arg passed');
  79. is(exception {$tr->deletePlan(1)}, undef,'deletePlan returns no error when int arg passed');
  80. is(exception {$tr->deleteProject(1)}, undef,'deleteProject returns no error when int arg passed');
  81. is(exception {$tr->deleteRun(1)}, undef,'deleteRun returns no error when int arg passed');
  82. is(exception {$tr->deleteSection(1)}, undef,'deleteSection returns no error when int arg passed');
  83. is(exception {$tr->deleteTestSuite(1)}, undef,'deleteTestSuite returns no error when int arg passed');
  84. is(exception {$tr->getCaseByID(1)}, undef,'getCaseByID returns no error when int arg passed');
  85. is(exception {$tr->getRuns(1)}, undef,'getRuns returns no error when int arg passed');
  86. is(exception {$tr->getRunsPaginated(1)}, undef,'getRunsPaginated returns no error when int arg passed');
  87. is(exception {$tr->getSectionByID(1)}, undef,'getSectionByID returns no error when int arg passed');
  88. is(exception {$tr->getTestByID(1)}, undef,'getTestByID returns no error when int arg passed');
  89. is(exception {$tr->getTestSuiteByID(1)}, undef,'getTestSuiteByID returns no error when int arg passed');
  90. is(exception {$tr->getPlans(1)}, undef,'getPlans returns no error when int arg passed');
  91. is(exception {$tr->getPlansPaginated(1)}, undef,'getPlansPaginated returns no error when int arg passed');
  92. is(exception {$tr->getProjectByID(1)}, undef,'getProjectByID returns no error when int arg passed');
  93. is(exception {$tr->getRunByID(1)}, undef,'getRunByID returns no error when int arg passed');
  94. is(exception {$tr->getTestSuites(1)}, undef,'getTestSuites returns no error when int arg passed');
  95. is(exception {$tr->getTests(1)}, undef,'getTests returns no error when int arg passed');
  96. is(exception {$tr->getUserByID(1)}, undef,'getUserByID returns no error when int arg passed');
  97. is(exception {$tr->getMilestones(1)}, undef,'getMilestones returns no error when int arg passed');
  98. is(exception {$tr->getPlanByID(1)}, undef,'getPlanByID returns no error when int arg passed');
  99. is(exception {$tr->getProjectByName('fake')}, undef,'getProjectByName returns no error when string arg passed');
  100. is(exception {$tr->getUserByEmail('tickle')}, undef,'getUserByEmail returns no error when string arg passed');
  101. is(exception {$tr->getUserByName('zap')}, undef,'getUserByName returns no error when string arg passed');
  102. is(exception {$tr->getCaseTypeByName('zap')}, undef,'getCaseTypeByName returns no error when string arg passed');
  103. is(exception {$tr->createProject('zippy')}, undef,'createProject returns no error when string arg passed');
  104. is(exception {$tr->getTestResults(1)}, undef,'getTestResults with 1 arg returns no error');
  105. is(exception {$tr->getMilestoneByID(1)}, undef,'getMilestoneByID with 1 arg returns no error');
  106. is(exception {$tr->getConfigurationGroups(1)},undef,'getConfigurationGroups with 1 arg returns no error');
  107. is(exception {$tr->getConfigurations(1)}, undef,'getConfigurations with 1 arg returns no error');
  108. is(exception {$tr->getChildRuns({}) }, undef,'getChildRuns returns no error when 1 argument passed');
  109. isnt(exception {$tr->createCase(1)}, undef,'createCase with 1 arg returns error');
  110. isnt(exception {$tr->createMilestone(1)}, undef,'createMilestone with 1 arg returns error');
  111. isnt(exception {$tr->createPlan(1)}, undef,'createPlan with 1 arg returns error');
  112. isnt(exception {$tr->createRun(1)}, undef,'createRun with 1 arg returns error');
  113. isnt(exception {$tr->createSection(1)}, undef,'createSection with 1 arg returns error');
  114. isnt(exception {$tr->createTestResults(1)}, undef,'createTestResults with 1 arg returns error');
  115. isnt(exception {$tr->createTestSuite(1)}, undef,'createTestSuite with 1 arg returns error');
  116. isnt(exception {$tr->getCaseByName(1)}, undef,'getCaseByName with 1 arg returns error');
  117. isnt(exception {$tr->getCases(1)}, undef,'getCases with 1 arg returns error');
  118. isnt(exception {$tr->getMilestoneByName(1)}, undef,'getMilestoneByName with 1 arg returns error');
  119. isnt(exception {$tr->getPlanByName(1)}, undef,'getPlanByName with 1 arg returns error');
  120. isnt(exception {$tr->getRunByName(1)}, undef,'getRunByName with 1 arg returns error');
  121. isnt(exception {$tr->getSectionByName(1)}, undef,'getSectionByName with 1 arg returns error');
  122. isnt(exception {$tr->getSections(1)}, undef,'getSections with 1 arg returns error');
  123. isnt(exception {$tr->sectionNamesToIds(1) },undef,'sectionNamesToIds returns error when 1 arguments are passed');
  124. isnt(exception {$tr->getTestByName(1)}, undef,'getTestByName with 1 arg returns error');
  125. isnt(exception {$tr->getTestSuiteByName(1)}, undef,'getTestSuiteByName with 1 arg returns error');
  126. isnt(exception {$tr->getChildRunByName({}) },undef,'getChildRunByName returns error when 1 argument passed');
  127. isnt( exception {$tr->createRunInPlan(1) },undef,'createRunInPlan returns error when 1 argument passed');
  128. isnt( exception {$tr->translateConfigNamesToIds(1)}, undef,'translateConfigNamesToIds returns error when 1 argument passed');
  129. isnt( exception {$tr->bulkAddResults(1)}, undef,'bulkAddResults returns error when 1 argument is passed');
  130. #2 arg functions
  131. is(exception {$tr->createMilestone(1,'whee')}, undef,'createMilestone with 2 args returns no error');
  132. is(exception {$tr->createPlan(1,'whee')}, undef,'createPlan with 2 args returns no error');
  133. is(exception {$tr->createTestResults(1,1)}, undef,'createTestResults with 2 args returns no error');
  134. is(exception {$tr->createTestSuite(1,'zugzug')}, undef,'createTestSuite with 2 args returns no error');
  135. is(exception {$tr->getMilestoneByName(1,'hug')}, undef,'getMilestoneByName with 2 args returns no error');
  136. is(exception {$tr->getPlanByName(1,'nugs')}, undef,'getPlanByName with 2 args returns no error');
  137. is(exception {$tr->getRunByName(1,'zoom')}, undef,'getRunByName with 2 args returns no error');
  138. is(exception {$tr->getSections(1,1)}, undef,'getSections with 2 args returns no error');
  139. is(exception {$tr->getTestByName(1,'poo')}, undef,'getTestByName with 2 args returns no error');
  140. is(exception {$tr->getTestSuiteByName(1,'zap')}, undef,'getTestSuiteByName with 2 args returns no error');
  141. is(exception {$tr->createCase(1,'whee')}, undef,'createCase with 2 args returns no error');
  142. is(exception {$tr->getChildRunByName({},'whee')},undef,'getChildRunByName returns no error when 2 arguments passed');
  143. is(exception {$tr->bulkAddResults(1,[])}, undef,'bulkAddResults returns no error when 2 arguments passed');
  144. is(exception {$tr->getCases(1,2)}, undef,'getCases with 2 args returns error');
  145. isnt(exception {$tr->createRun(1,1)}, undef,'createRun with 2 args returns error');
  146. isnt(exception {$tr->createSection(1,1)}, undef,'createSection with 2 args returns error');
  147. isnt(exception {$tr->getCaseByName(1,1)}, undef,'getCaseByName with 2 args returns error');
  148. isnt(exception {$tr->getSectionByName(1,1)}, undef,'getSectionByName with 2 args returns error');
  149. isnt(exception {$tr->sectionNamesToIds(1,1) },undef,'sectionNamesToIds returns error when 2 arguments are passed');
  150. isnt( exception {$tr->createRunInPlan(1,1) },undef,'createRunInPlan returns error when 2 arguments passed');
  151. #3 arg functions
  152. is(exception {$tr->createRun(1,1,'whee')}, undef,'createRun with 3 args returns no error');
  153. is(exception {$tr->createSection(1,1,'whee')}, undef,'createSection with 3 args returns no error');
  154. is(exception {$tr->getCases(1,2,{})}, undef,'getCases with 3 args returns no error');
  155. is(exception {$tr->getSectionByName(1,1,'zip')}, undef,'getSectionByName with 3 args returns no error');
  156. is(exception {$tr->createRunInPlan(1,1,'nugs') },undef,'createRunInPlan with 3 args returns no error');
  157. is(exception {$tr->getCaseByName(1,1,'whee')}, undef,'getCaseByName with 3 args returns no error');
  158. #4 arg functions
  159. is(exception {$tr->getCaseByName(1,1,'hug', {})}, undef,'getCaseByName with 4 args returns no error');