From 7ded28be567fd52b2ab752c30203e59f307ebdcd Mon Sep 17 00:00:00 2001 From: dklawren Date: Tue, 24 Jul 2018 12:39:02 -0400 Subject: Bug 1477894 - get_attachment_revisions() should be returning an empty list, instead of a list of [0] --- t/phabbugz.t | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 't') diff --git a/t/phabbugz.t b/t/phabbugz.t index 610089851..ba2f35e1d 100644 --- a/t/phabbugz.t +++ b/t/phabbugz.t @@ -62,7 +62,8 @@ local Bugzilla->params->{phabricator_base_uri} = 'http://fake.fabricator.tld'; my $Bugzilla = mock 'Bugzilla' => ( override => [ - 'dbh' => sub { mock() }, + 'dbh' => sub { mock() }, + 'user' => sub { Bugzilla::User->new({ name => 'phab-bot@bmo.tld' }) }, ], ); @@ -168,9 +169,53 @@ do { 'post' => sub { my ($self, $url, $params) = @_; if ($url =~ /differential\.revision\.search/) { - my $data = decode_json($params->{params}); - my $content = '{"error_info":null,"error_code":null,"result":{"cursor":{"after":null,"order":null,"limit":100,"before":null},"query":{"queryKey":"all"},"maps":{},"data":[]}}'; - return mock { is_error => 0, content => $content}; + my $content = < 0, content => $content }; } else { return mock { is_error => 1, message => "bad request" }; @@ -183,13 +228,14 @@ do { attachments => [ mock { contenttype => 'text/x-phabricator-request', - filename => 'phabricator-D9999', + filename => 'phabricator-D9999-url.txt', }, ] }; my $revisions = get_attachment_revisions($bug); is(ref($revisions), 'ARRAY', 'it is an array ref'); isa_ok($revisions->[0], 'Bugzilla::Extension::PhabBugz::Revision'); + is($revisions->[0]->bug_id, 23, 'Bugzila ID is 23'); ok( try { $revisions->[0]->update }, 'update revision'); }; -- cgit v1.2.3-24-g4f1b