Browse Source

Fix #102: Add way to get child sections & consider them in TAP parser
when spawning.

George S. Baugh 9 năm trước cách đây
mục cha
commit
1e3a42b245

+ 2 - 0
Changes

@@ -3,6 +3,8 @@ Revision history for Perl module TestRail::API
 0.037 2016-04-?? TEODESIAN
     - Fix incorrect POD for TestRail::API::createRunInPlan
     - Add testrail-results binary and TestRail::Utils::Find::getResults.
+    - Add TestRail::API::getChildSections, and modify Test::Rail::Parser to recursively search passed sections when spawning runs
+    - Change TestRail::API::getSections to cache the sections in a project.
 
 0.036 2016-04-25 TEODESIAN
     - Fix using wrong perl during testsuite when running binaries

+ 1 - 0
dist.ini

@@ -128,6 +128,7 @@ stopwords = judgements
 stopwords = bailoutCallback
 stopwords = findResults
 stopwords = cachefile
+stopwords = getChildSections
 
 [PkgVersion]
 [AutoPrereqs]

+ 6 - 0
lib/Test/Rail/Parser.pm

@@ -252,6 +252,12 @@ sub new {
             confess("Sections passed to spawn must be ARRAYREF") unless (reftype($tropts->{'sections'}) || 'undef') eq 'ARRAY';
             @{$tropts->{'sections'}} = $tr->sectionNamesToIds($tropts->{'project_id'},$tropts->{'testsuite_id'},@{$tropts->{'sections'}});
             foreach my $section (@{$tropts->{'sections'}}) {
+                #Get the child sections, and append them to our section list so we get their cases too.
+                my $append_sections = $tr->getChildSections($tropts->{'project_id'}, { 'id' => $section, 'suite_id' => $tropts->{'testsuite_id'} } );
+                @$append_sections = grep {my $sc = $_; !scalar(grep {$_ == $sc->{'id'}} @{$tropts->{'sections'}}) } @$append_sections; #de-dup in case the user added children to the list
+                @$append_sections = map { $_->{'id'} } @$append_sections;
+                push(@{$tropts->{'sections'}},@$append_sections);
+
                 my $section_cases = $tr->getCases($tropts->{'project_id'},$tropts->{'testsuite_id'},{ 'section_id' => $section });
                 push(@$cases,@$section_cases) if (reftype($section_cases) || 'undef') eq 'ARRAY';
             }

+ 39 - 1
lib/TestRail/API.pm

@@ -677,7 +677,11 @@ sub getSections {
     state $check = compile(Object, Int, Int);
     my ($self,$project_id,$suite_id) = $check->(@_);
 
-    return $self->_doRequest("index.php?/api/v2/get_sections/$project_id&suite_id=$suite_id");
+    #Cache sections to reduce requests in tight loops
+    return $self->{'sections'}->{$project_id} if $self->{'sections'}->{$project_id};
+    $self->{'sections'}->{$project_id} = $self->_doRequest("index.php?/api/v2/get_sections/$project_id&suite_id=$suite_id");
+
+    return $self->{'sections'}->{$project_id};
 }
 
 =head2 B<getSectionByID (section_id)>
@@ -737,6 +741,40 @@ sub getSectionByName {
     return 0;
 }
 
+=head2 B<getChildSections ($project_id, section)>
+
+Gets desired section's child sections.
+
+=over 4
+
+=item INTEGER C<PROJECT_ID> - parent project ID of section.
+
+=item HASHREF C<SECTION> - section definition HASHREF.
+
+=back
+
+Returns ARRAYREF of section definition HASHREF.  ARRAYREF is empty if there are none.
+
+Recursively searches for children, so the children of child sections will be returned as well.
+
+    $tr->getChildSections($section);
+
+=cut
+
+sub getChildSections {
+    state $check = compile(Object, Int, HashRef);
+    my ($self, $project_id, $section) = $check->(@_);
+
+    my $sections_orig = $self->getSections($project_id,$section->{suite_id});
+    return [] if !$sections_orig || (reftype($sections_orig) || 'undef') ne 'ARRAY';
+    my @sections = grep { $_->{'parent_id'} ? $_->{'parent_id'} == $section->{'id'} : 0 } @$sections_orig;
+    foreach my $sec (@sections) {
+        push(@sections, grep { $_->{'parent_id'} ? $_->{'parent_id'} == $sec->{'id'} : 0 } @$sections_orig);
+    }
+    return \@sections;
+}
+
+
 =head2 sectionNamesToIds(project_id,suite_id,names)
 
 Convenience method to translate a list of section names to TestRail section IDs.

+ 17 - 1
t/Test-Rail-Parser.t

@@ -10,7 +10,7 @@ use Scalar::Util qw{reftype};
 use TestRail::API;
 use Test::LWP::UserAgent::TestRailMock;
 use Test::Rail::Parser;
-use Test::More 'tests' => 115;
+use Test::More 'tests' => 117;
 use Test::Fatal qw{exception};
 use Test::Deep qw{cmp_deeply};
 use Capture::Tiny qw{capture};
@@ -546,3 +546,19 @@ if (!$res) {
     my $srs = $tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
     is($srs->[-1]->{'content'},"Bail Out!.","Bailout noted in step results");
 }
+
+#Check section spawn recursion is done correctly
+undef $opts->{'tap'};
+$opts->{'source'} = 't/pass.test';
+$opts->{'testsuite_id'} = 5;
+$opts->{'project_id'} = 3;
+$opts->{'run'} = 'zippyRun';
+$opts->{'sections'} = ['Recursing section','grandchild'];
+
+$res = exception { $tap = Test::Rail::Parser->new($opts) };
+is($res,undef,"TR Parser runs all the way through when recursing sections");
+
+if (!$res) {
+    $tap->run();
+    is($tap->{'errors'},0,"No errors encountered uploading case results");
+}

+ 42 - 0
t/TestRail-API-sections.t

@@ -0,0 +1,42 @@
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use TestRail::API;
+use Test::LWP::UserAgent::TestRailMock;
+
+use Test::More tests => 2;
+use Test::Fatal;
+use Test::Deep;
+use Scalar::Util ();
+use Capture::Tiny qw{capture};
+
+my $apiurl = $ENV{'TESTRAIL_API_URL'};
+my $login  = $ENV{'TESTRAIL_USER'};
+my $pw     = $ENV{'TESTRAIL_PASSWORD'};
+
+#Mock if nothing is provided
+my $is_mock = (!$apiurl && !$login && !$pw);
+($apiurl,$login,$pw) = ('http://testrail.local','teodesian@cpan.org','fake') if $is_mock;
+
+my $tr = new TestRail::API($apiurl,$login,$pw,undef,1);
+
+#Mock if necesary
+$tr->{'debug'} = 0;
+$tr->{'browser'} = $Test::LWP::UserAgent::TestRailMock::mockObject if $is_mock;
+
+#This is a mock-only test.
+my $project = $tr->getProjectByName('zippy');
+my $suite   = $tr->getTestSuiteByName($project->{'id'},'Master');
+my $section = $tr->getSectionByName($project->{'id'},$suite->{'id'},'Recursing section');
+
+my $children = $tr->getChildSections($project->{'id'},$section);
+
+my @expected = qw{child grandchild great-grandchild};
+my @actual   = map {$_->{'name'} } @$children;
+cmp_bag(\@actual,\@expected,"Got child suites recursively");
+cmp_bag($tr->getChildSections($project->{'id'},{ 'suite_id' => 999999999999999, 'id' => 9999999999999999 }),[],"Nothing returned when bogus section passed");
+
+1;

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
t/data/faketest_cache.json


+ 362 - 2
t/lib/Test/LWP/UserAgent/TestRailMock.pm

@@ -170,7 +170,7 @@ $VAR4 = bless( {
                  'content-type' => 'application/json; charset=utf-8',
                  'server' => 'Apache/2.4.7 (Ubuntu)'
                }, 'HTTP::Headers' );
-$VAR5 = '[{"id":9,"name":"CRUSH ALL HUMANS","announcement":"Robo-Signed Soviet 5 Year Project","show_announcement":false,"is_completed":false,"completed_on":null,"suite_mode":3,"url":"http:\\/\\/testrail.local\\/\\/index.php?\\/projects\\/overview\\/9"},{"id":10,"name":"TestProject","is_completed":false}]';
+$VAR5 = '[{"id":9,"name":"CRUSH ALL HUMANS","announcement":"Robo-Signed Soviet 5 Year Project","show_announcement":false,"is_completed":false,"completed_on":null,"suite_mode":3,"url":"http:\\/\\/testrail.local\\/\\/index.php?\\/projects\\/overview\\/9"},{"id":10,"name":"TestProject","is_completed":false},{"id":3,"name":"zippy","announcement":null,"show_announcement":false,"is_completed":false,"completed_on":null,"suite_mode":2,"url":"http:\\/\\/testrail.local\\/index.php?\\/projects\\/overview\\/3"}]';
 $mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
 
 }
@@ -1431,7 +1431,7 @@ $VAR4 = bless( {
                  'content-type' => 'application/json; charset=utf-8',
                  'server' => 'Apache/2.4.7 (Ubuntu)'
                }, 'HTTP::Headers' );
-$VAR5 = '[{"display_order":1,"system_name":"custom_step_results","name":"step_results","description":"Step by step results","is_active":1,"type_id":11,"configs":[{"options":{"is_required":0,"format":"markdown","has_actual":1,"has_expected":1},"context":{"project_ids":[5],"is_global":1},"id":"43410543-edaf-44d2-91fc-58a6f9b3f743"},{"options":{"is_required":1,"format":"markdown","has_actual":1,"has_expected":1},"context":{"project_ids":[1],"is_global":1},"id":"0ab86184-0468-40d8-a385-a9b3a1ec41a4"},{"options":{"is_required":0,"format":"markdown","has_actual":1,"has_expected":1},"context":{"project_ids":[10],"is_global":1},"id":"43ebdf1f-c9b9-4b91-a729-5c9f21252f00"}],"id":6,"label":"Step Results"}]';
+$VAR5 = '[{"display_order":1,"system_name":"custom_step_results","name":"step_results","description":"Step by step results","is_active":1,"type_id":11,"configs":[{"options":{"is_required":0,"format":"markdown","has_actual":1,"has_expected":1},"context":{"project_ids":[5,3],"is_global":1},"id":"43410543-edaf-44d2-91fc-58a6f9b3f743"},{"options":{"is_required":1,"format":"markdown","has_actual":1,"has_expected":1},"context":{"project_ids":[1],"is_global":1},"id":"0ab86184-0468-40d8-a385-a9b3a1ec41a4"},{"options":{"is_required":0,"format":"markdown","has_actual":1,"has_expected":1},"context":{"project_ids":[10],"is_global":1},"id":"43ebdf1f-c9b9-4b91-a729-5c9f21252f00"}],"id":6,"label":"Step Results"}]';
 $mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
 
 }
@@ -2908,6 +2908,366 @@ $mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4,
 
 }
 
+########################
+# getChildSections mocks
+########################
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_suites/3';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:07:51 GMT',
+                 'connection' => 'close',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'content-length' => '199',
+                 '::std_case' => {
+                                   'client-date' => 'Client-Date',
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-peer' => 'Client-Peer',
+                                   'x-powered-by' => 'X-Powered-By'
+                                 },
+                 'client-date' => 'Wed, 10 Aug 2016 03:07:51 GMT',
+                 'client-response-num' => 1,
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'client-peer' => '192.168.122.217:80',
+                 'content-type' => 'application/json; charset=utf-8'
+               }, 'HTTP::Headers' );
+$VAR5 = '[{"id":5,"name":"Master","description":null,"project_id":3,"is_master":true,"is_baseline":false,"is_completed":false,"completed_on":null,"url":"http:\\/\\/testrail.local\\/index.php?\\/suites\\/view\\/5"}]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_sections/3&suite_id=5';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 '::std_case' => {
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-peer' => 'Client-Peer',
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-date' => 'Client-Date'
+                                 },
+                 'client-date' => 'Wed, 10 Aug 2016 03:07:52 GMT',
+                 'date' => 'Wed, 10 Aug 2016 03:07:51 GMT',
+                 'connection' => 'close',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'content-length' => '835',
+                 'content-type' => 'application/json; charset=utf-8',
+                 'client-peer' => '192.168.122.217:80',
+                 'client-response-num' => 1,
+                 'server' => 'Apache/2.4.7 (Ubuntu)'
+               }, 'HTTP::Headers' );
+$VAR5 = '[{"id":6,"suite_id":5,"name":"Column A","description":null,"parent_id":null,"display_order":1,"depth":0},{"id":8,"suite_id":5,"name":"zippy","description":null,"parent_id":6,"display_order":2,"depth":1},{"id":7,"suite_id":5,"name":"Column B","description":null,"parent_id":null,"display_order":3,"depth":0},{"id":9,"suite_id":5,"name":"zippy","description":null,"parent_id":7,"display_order":4,"depth":1},{"id":11,"suite_id":5,"name":"Recursing section","description":null,"parent_id":null,"display_order":5,"depth":0},{"id":12,"suite_id":5,"name":"child","description":null,"parent_id":11,"display_order":6,"depth":1},{"id":13,"suite_id":5,"name":"grandchild","description":null,"parent_id":12,"display_order":7,"depth":2},{"id":14,"suite_id":5,"name":"great-grandchild","description":null,"parent_id":13,"display_order":8,"depth":3}]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_configs/3';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'client-response-num' => 1,
+                 'content-length' => '2',
+                 'connection' => 'close',
+                 'content-type' => 'application/json; charset=utf-8',
+                 '::std_case' => {
+                                   'client-date' => 'Client-Date',
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-peer' => 'Client-Peer',
+                                   'client-response-num' => 'Client-Response-Num'
+                                 },
+                 'client-peer' => '192.168.122.217:80',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:47 GMT',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'date' => 'Wed, 10 Aug 2016 03:39:47 GMT'
+               }, 'HTTP::Headers' );
+$VAR5 = '[]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_runs/3&offset=0&limit=250';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:39:47 GMT',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:47 GMT',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'client-peer' => '192.168.122.217:80',
+                 'content-type' => 'application/json; charset=utf-8',
+                 '::std_case' => {
+                                   'client-peer' => 'Client-Peer',
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-date' => 'Client-Date',
+                                   'x-powered-by' => 'X-Powered-By'
+                                 },
+                 'connection' => 'close',
+                 'content-length' => '588',
+                 'client-response-num' => 1
+               }, 'HTTP::Headers' );
+$VAR5 = '[{"id":32,"suite_id":5,"name":"Master Shake","description":null,"milestone_id":null,"assignedto_id":null,"include_all":true,"is_completed":false,"completed_on":null,"config":null,"config_ids":[],"passed_count":1,"blocked_count":0,"untested_count":3,"retest_count":0,"failed_count":0,"custom_status1_count":0,"custom_status2_count":0,"custom_status3_count":0,"custom_status4_count":0,"custom_status5_count":0,"custom_status6_count":0,"custom_status7_count":0,"project_id":3,"plan_id":null,"created_on":1470345740,"created_by":1,"url":"http:\\/\\/testrail.local\\/index.php?\\/runs\\/view\\/32"}]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_sections/3&suite_id=5';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:39:47 GMT',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'client-peer' => '192.168.122.217:80',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:47 GMT',
+                 '::std_case' => {
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-peer' => 'Client-Peer',
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-date' => 'Client-Date'
+                                 },
+                 'content-type' => 'application/json; charset=utf-8',
+                 'client-response-num' => 1,
+                 'content-length' => '835',
+                 'connection' => 'close'
+               }, 'HTTP::Headers' );
+$VAR5 = '[{"id":6,"suite_id":5,"name":"Column A","description":null,"parent_id":null,"display_order":1,"depth":0},{"id":8,"suite_id":5,"name":"zippy","description":null,"parent_id":6,"display_order":2,"depth":1},{"id":7,"suite_id":5,"name":"Column B","description":null,"parent_id":null,"display_order":3,"depth":0},{"id":9,"suite_id":5,"name":"zippy","description":null,"parent_id":7,"display_order":4,"depth":1},{"id":11,"suite_id":5,"name":"Recursing section","description":null,"parent_id":null,"display_order":5,"depth":0},{"id":12,"suite_id":5,"name":"child","description":null,"parent_id":11,"display_order":6,"depth":1},{"id":13,"suite_id":5,"name":"grandchild","description":null,"parent_id":12,"display_order":7,"depth":2},{"id":14,"suite_id":5,"name":"great-grandchild","description":null,"parent_id":13,"display_order":8,"depth":3}]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_cases/3&suite_id=5&section_id=11';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:39:47 GMT',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'client-peer' => '192.168.122.217:80',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 '::std_case' => {
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-date' => 'Client-Date',
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-peer' => 'Client-Peer'
+                                 },
+                 'content-type' => 'application/json; charset=utf-8',
+                 'client-response-num' => 1,
+                 'content-length' => '2',
+                 'connection' => 'close'
+               }, 'HTTP::Headers' );
+$VAR5 = '[]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_cases/3&suite_id=5&section_id=14';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'client-peer' => '192.168.122.217:80',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'content-type' => 'application/json; charset=utf-8',
+                 '::std_case' => {
+                                   'client-peer' => 'Client-Peer',
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-date' => 'Client-Date',
+                                   'x-powered-by' => 'X-Powered-By'
+                                 },
+                 'connection' => 'close',
+                 'content-length' => '321',
+                 'client-response-num' => 1
+               }, 'HTTP::Headers' );
+$VAR5 = '[{"id":16,"title":"pass.test","section_id":14,"template_id":1,"type_id":6,"priority_id":4,"milestone_id":null,"refs":null,"created_by":1,"created_on":1470799296,"updated_by":1,"updated_on":1470799296,"estimate":null,"estimate_forecast":null,"suite_id":5,"custom_preconds":null,"custom_steps":null,"custom_expected":null}]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_cases/3&suite_id=5&section_id=12';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 'client-peer' => '192.168.122.217:80',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 '::std_case' => {
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-peer' => 'Client-Peer',
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-date' => 'Client-Date'
+                                 },
+                 'content-type' => 'application/json; charset=utf-8',
+                 'client-response-num' => 1,
+                 'content-length' => '321',
+                 'connection' => 'close'
+               }, 'HTTP::Headers' );
+$VAR5 = '[{"id":17,"title":"fake.test","section_id":12,"template_id":1,"type_id":6,"priority_id":4,"milestone_id":null,"refs":null,"created_by":1,"created_on":1470799305,"updated_by":1,"updated_on":1470799305,"estimate":null,"estimate_forecast":null,"suite_id":5,"custom_preconds":null,"custom_steps":null,"custom_expected":null}]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_cases/3&suite_id=5&section_id=13';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 'client-peer' => '192.168.122.217:80',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'content-type' => 'application/json; charset=utf-8',
+                 '::std_case' => {
+                                   'client-date' => 'Client-Date',
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-peer' => 'Client-Peer',
+                                   'client-response-num' => 'Client-Response-Num'
+                                 },
+                 'client-response-num' => 1,
+                 'connection' => 'close',
+                 'content-length' => '321'
+               }, 'HTTP::Headers' );
+$VAR5 = '[{"id":18,"title":"skip.test","section_id":13,"template_id":1,"type_id":6,"priority_id":4,"milestone_id":null,"refs":null,"created_by":1,"created_on":1470799317,"updated_by":1,"updated_on":1470799317,"estimate":null,"estimate_forecast":null,"suite_id":5,"custom_preconds":null,"custom_steps":null,"custom_expected":null}]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/add_run/3';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:48 GMT',
+                 'client-peer' => '192.168.122.217:80',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 '::std_case' => {
+                                   'client-peer' => 'Client-Peer',
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-date' => 'Client-Date',
+                                   'x-powered-by' => 'X-Powered-By'
+                                 },
+                 'content-type' => 'application/json; charset=utf-8',
+                 'connection' => 'close',
+                 'content-length' => '625',
+                 'client-response-num' => 1
+               }, 'HTTP::Headers' );
+$VAR5 = '{"id":36,"suite_id":5,"name":"zippyRun","description":"Automatically created Run from TestRail::API","milestone_id":null,"assignedto_id":null,"include_all":false,"is_completed":false,"completed_on":null,"config":null,"config_ids":[],"passed_count":0,"blocked_count":0,"untested_count":3,"retest_count":0,"failed_count":0,"custom_status1_count":0,"custom_status2_count":0,"custom_status3_count":0,"custom_status4_count":0,"custom_status5_count":0,"custom_status6_count":0,"custom_status7_count":0,"project_id":3,"plan_id":null,"created_on":1470800388,"created_by":1,"url":"http:\\/\\/testrail.local\\/index.php?\\/runs\\/view\\/36"}';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_tests/36';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'date' => 'Wed, 10 Aug 2016 03:39:49 GMT',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:49 GMT',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'client-peer' => '192.168.122.217:80',
+                 'content-type' => 'application/json; charset=utf-8',
+                 '::std_case' => {
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-peer' => 'Client-Peer',
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-date' => 'Client-Date'
+                                 },
+                 'content-length' => '820',
+                 'connection' => 'close',
+                 'client-response-num' => 1
+               }, 'HTTP::Headers' );
+$VAR5 = '[{"id":43,"case_id":17,"status_id":3,"assignedto_id":null,"run_id":36,"title":"fake.test","template_id":1,"type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null},{"id":44,"case_id":18,"status_id":3,"assignedto_id":null,"run_id":36,"title":"skip.test","template_id":1,"type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null},{"id":42,"case_id":16,"status_id":3,"assignedto_id":null,"run_id":36,"title":"pass.test","template_id":1,"type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null}]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/add_result/42';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'client-response-num' => 1,
+                 'connection' => 'close',
+                 'content-length' => '194',
+                 'content-type' => 'application/json; charset=utf-8',
+                 '::std_case' => {
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-peer' => 'Client-Peer',
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-date' => 'Client-Date'
+                                 },
+                 'client-peer' => '192.168.122.217:80',
+                 'server' => 'Apache/2.4.7 (Ubuntu)',
+                 'client-date' => 'Wed, 10 Aug 2016 03:39:49 GMT',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.14',
+                 'date' => 'Wed, 10 Aug 2016 03:39:49 GMT'
+               }, 'HTTP::Headers' );
+$VAR5 = '{"id":516,"test_id":42,"status_id":1,"created_by":1,"created_on":1470800389,"assignedto_id":null,"comment":"[22:39:48 Aug  9 2016 (0s)] ok 1 - yay!","version":null,"elapsed":null,"defects":null}';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+{
+
+$VAR1 = 'index.php?/api/v2/get_plans/3';
+$VAR2 = '200';
+$VAR3 = 'OK';
+$VAR4 = bless( {
+                 'connection' => 'close',
+                 'x-powered-by' => 'PHP/5.5.9-1ubuntu4.5',
+                 'client-response-num' => 1,
+                 'date' => 'Tue, 23 Dec 2014 20:02:10 GMT',
+                 'client-peer' => '192.168.122.217:80',
+                 'content-length' => '554',
+                 '::std_case' => {
+                                   'client-date' => 'Client-Date',
+                                   'x-powered-by' => 'X-Powered-By',
+                                   'client-response-num' => 'Client-Response-Num',
+                                   'client-peer' => 'Client-Peer'
+                                 },
+                 'client-date' => 'Tue, 23 Dec 2014 20:02:10 GMT',
+                 'content-type' => 'application/json; charset=utf-8',
+                 'server' => 'Apache/2.4.7 (Ubuntu)'
+               }, 'HTTP::Headers' );
+$VAR5 = '[]';
+$mockObject->map_response(qr/\Q$VAR1\E/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
+
+}
+
+
+###########
+#Lock mocks
+###########
+
 sub lockMockStep0 {
 
 $VAR1 = 'index.php?/api/v2/get_tests/1099';

+ 4 - 4
t/testrail-results.t

@@ -60,7 +60,7 @@ use warnings;
 my @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake t/fake.test };
 my ($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
 is($code, 0, "Exit code OK looking for results of fake.test");
-like($out,qr/fake\.test was present in 514 runs/,"Gets correct # of runs with test inside it");
+like($out,qr/fake\.test was present in 515 runs/,"Gets correct # of runs with test inside it");
 
 #check project filters
 @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject t/fake.test };
@@ -73,7 +73,7 @@ like($out,qr/fake\.test was present in 10 runs/,"Gets correct # of runs with tes
 push(@args,'mah dubz plan', 't/fake.test');
 ($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
 is($code, 0, "Exit code OK looking for results of fake.test");
-like($out,qr/fake\.test was present in 257 runs/,"Gets correct # of runs with test inside it when filtering by plan name");
+like($out,qr/fake\.test was present in 258 runs/,"Gets correct # of runs with test inside it when filtering by plan name");
 
 #check run filters
 @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --run FinalRun t/fake.test};
@@ -85,8 +85,8 @@ like($out,qr/fake\.test was present in 1 runs/,"Gets correct # of runs with test
 @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --grep zippy t/fake.test};
 ($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
 is($code, 0, "Exit code OK looking for results of fake.test");
-like($out,qr/Retest: 514/,"Gets correct # & status of runs with test inside it when grepping");
-unlike($out,qr/Failed: 514/,"Gets correct # & status of runs with test inside it when grepping");
+like($out,qr/Retest: 515/,"Gets correct # & status of runs with test inside it when grepping");
+unlike($out,qr/Failed: 515/,"Gets correct # & status of runs with test inside it when grepping");
 
 @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake --json t/fake.test };
 ($out,$code) = TestRail::Bin::Results::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác