Переглянути джерело

Fix some optional args to be so, add in offset for get_results

George S. Baugh 11 роки тому
батько
коміт
9150a22b64
2 змінених файлів з 10 додано та 5 видалено
  1. 1 0
      Changes
  2. 9 5
      lib/TestRail/API.pm

+ 1 - 0
Changes

@@ -7,6 +7,7 @@ Revision history for Perl module TestRail::API
     - Add class usage checks and test for that as author tests
     - Add tests for the server going away, and fix issues encountered therein.
     - Add fatal type checking of inputs for all methods, add test to make sure exceptions thrown correctly
+    - Add offset argument to getTestResults call.
 
 0.011 2014-12-04 TEODESIAN
     - Converted to using dzil, and testing using TestingMania

+ 9 - 5
lib/TestRail/API.pm

@@ -777,7 +777,7 @@ Creates a test case.
 
 =item STRING C<TITLE> - Case title.
 
-=item INTEGER C<TYPE_ID> - desired test type's ID.
+=item INTEGER C<TYPE_ID> (optional) - desired test type's ID.  Defaults to whatever your TR install considers the default type.
 
 =item HASHREF C<OPTIONS> (optional) - Custom fields in the case are the keys, set to the values provided.  See TestRail API documentation for more info.
 
@@ -809,7 +809,7 @@ sub createCase {
     confess("Object methods must be called by an instance") unless ref($self);
     confess("Section ID ($section_id) must be integer") unless $self->_checkInteger($section_id);
     confess("title must be string") unless $self->_checkString($title);
-    confess("Type ID must be integer") unless $self->_checkInteger($type_id);
+    confess("Type ID must be integer") unless !defined($type_id) || $self->_checkInteger($type_id);
     confess("Options must be HASHREF") unless !defined($opts) || (reftype($opts) || 'undef') ne 'HASH';
     confess("Extras must be HASHREF") unless !defined($extras) || (reftype($extras) || 'undef') ne 'HASH';
 
@@ -1599,7 +1599,9 @@ Get the recorded results for desired test, limiting output to 'limit' entries.
 
 =item INTEGER C<TEST_ID> - ID of desired test
 
-=item POSITIVE INTEGER C<LIMIT> - provide no more than this number of results.
+=item POSITIVE INTEGER C<LIMIT> (OPTIONAL) - provide no more than this number of results.
+
+=item INTEGER C<OFFSET> (OPTIONAL) - Offset to begin viewing resultset at.
 
 =back
 
@@ -1608,12 +1610,14 @@ Returns ARRAYREF of result definition HASHREFs.
 =cut
 
 sub getTestResults {
-    my ($self,$test_id,$limit) = @_;
+    my ($self,$test_id,$limit,$offset) = @_;
     confess("Object methods must be called by an instance") unless ref($self);
     confess("Test ID must be positive integer") unless $self->_checkInteger($test_id);
-    confess("Result limitation must be positive integer") unless $self->_checkInteger($limit) && $limit > 0;
+    confess("Result limitation must be positive integer") unless !defined($limit) || ($self->_checkInteger($limit) && $limit > 0);
+    confess("Result offset must be integer") unless !defined($offset) || $self->_checkInteger($offset);
     my $url = "index.php?/api/v2/get_results/$test_id";
     $url .= "&limit=$limit" if defined($limit);
+    $url .= "&offset=$offset" if defined($offset);
     return $self->_doRequest($url);
 }