summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authordklawren <dklawren@users.noreply.github.com>2018-07-24 18:39:02 +0200
committerGitHub <noreply@github.com>2018-07-24 18:39:02 +0200
commit7ded28be567fd52b2ab752c30203e59f307ebdcd (patch)
tree15822d31450c63414ae6acbe2460315af8394606 /t
parent345e686485e484e087ea58c988e4831209c39554 (diff)
downloadbugzilla-7ded28be567fd52b2ab752c30203e59f307ebdcd.tar.gz
bugzilla-7ded28be567fd52b2ab752c30203e59f307ebdcd.tar.xz
Bug 1477894 - get_attachment_revisions() should be returning an empty list, instead of a list of [0]
Diffstat (limited to 't')
-rw-r--r--t/phabbugz.t56
1 files changed, 51 insertions, 5 deletions
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 = <<JSON;
+{
+ "error_info": null,
+ "error_code": null,
+ "result": {
+ "data": [
+ {
+ "id": 9999,
+ "type": "DREV",
+ "phid": "PHID-DREV-uozm3ggfp7e7uoqegmc3",
+ "fields": {
+ "title": "Added .arcconfig",
+ "summary": "Added .arcconfig",
+ "authorPHID": "PHID-USER-4wigy3sh5fc5t74vapwm",
+ "dateCreated": 1507666113,
+ "dateModified": 1508514027,
+ "policy": {
+ "view": "public",
+ "edit": "admin"
+ },
+ "bugzilla.bug-id": "23",
+ "status": {
+ "value": "needs-review",
+ "name": "Needs Review",
+ "closed": false,
+ "color.ansi": "magenta"
+ }
+ },
+ "attachments": {
+ "reviewers": {
+ "reviewers": []
+ },
+ "subscribers": {
+ "subscriberPHIDs": [],
+ "subscriberCount": 0,
+ "viewerIsSubscribed": true
+ },
+ "projects": {
+ "projectPHIDs": []
+ }
+ }
+ }
+ ]
+ }
+}
+JSON
+ return mock { is_error => 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');
};