Skip to content

Commit

Permalink
Merge pull request screwdriver-cd#8 from screwdriver-cd/bugggg
Browse files Browse the repository at this point in the history
Add json:true option for request
  • Loading branch information
tkyi authored Oct 21, 2016
2 parents 1b1b039 + 0a03545 commit ecfba30
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
21 changes: 14 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class BitbucketScm extends Scm {
`/refs/branches/${repoInfo.branch}?access_key=${config.token}`;
const options = {
url: branchUrl,
method: 'GET'
method: 'GET',
json: true
};

return this.breaker.runCommand(options)
Expand Down Expand Up @@ -164,7 +165,8 @@ class BitbucketScm extends Scm {
_decorateAuthor(config) {
const options = {
url: `${USER_URL}/${config.username}?access_key=${config.token}`,
method: 'GET'
method: 'GET',
json: true
};

return this.breaker.runCommand(options)
Expand Down Expand Up @@ -198,7 +200,8 @@ class BitbucketScm extends Scm {
const scm = getScmUriParts(config.scmUri);
const options = {
url: `${REPO_URL}/${scm.repoId}?access_key=${config.token}`,
method: 'GET'
method: 'GET',
json: true
};

return this.breaker.runCommand(options)
Expand Down Expand Up @@ -230,7 +233,8 @@ class BitbucketScm extends Scm {
const scm = getScmUriParts(config.scmUri);
const options = {
url: `${REPO_URL}/${scm.repoId}/commit/${config.sha}?access_key=${config.token}`,
method: 'GET'
method: 'GET',
json: true
};

return this.breaker.runCommand(options)
Expand Down Expand Up @@ -267,7 +271,8 @@ class BitbucketScm extends Scm {
`${REPO_URL}/${scm.repoId}/refs/branches/${scm.branch}?access_key=${config.token}`;
const options = {
url: branchUrl,
method: 'GET'
method: 'GET',
json: true
};

return this.breaker.runCommand(options)
Expand Down Expand Up @@ -298,7 +303,8 @@ class BitbucketScm extends Scm {
const fileUrl = `${urlRoot}/${urlSuffix}?${urlParameters}`;
const options = {
url: fileUrl,
method: 'GET'
method: 'GET',
json: true
};

return this.breaker.runCommand(options)
Expand All @@ -325,7 +331,8 @@ class BitbucketScm extends Scm {
const [owner, uuid] = repoId.split('/');
const options = {
url: `${API_URL_V2}/repositories/${owner}`,
method: 'GET'
method: 'GET',
json: true
};

if (desiredAccess === 'admin') {
Expand Down
36 changes: 24 additions & 12 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ describe('index', () => {
};
expectedOptions = {
url: `${apiUrl}/mynewbranch?access_key=myAccessToken`,
method: 'GET'
method: 'GET',
json: true
};
requestMock.yieldsAsync(null, fakeResponse, fakeResponse.body);
});
Expand All @@ -80,7 +81,8 @@ describe('index', () => {

expectedOptions = {
url: `${apiUrl}/master?access_key=myAccessToken`,
method: 'GET'
method: 'GET',
json: true
};

return scm.parseUrl({
Expand Down Expand Up @@ -246,7 +248,8 @@ describe('index', () => {
const apiUrl = `${API_URL_V2}/users/batman?access_key=${token}`;
const expectedOptions = {
url: apiUrl,
method: 'GET'
method: 'GET',
json: true
};
let fakeResponse;

Expand Down Expand Up @@ -333,7 +336,8 @@ describe('index', () => {
const selfLink = 'https://bitbucket.org/d2lam2/test';
const repoOptions = {
url: apiUrl,
method: 'GET'
method: 'GET',
json: true
};
let fakeResponse;
let expectedOptions;
Expand All @@ -352,7 +356,8 @@ describe('index', () => {
};
expectedOptions = {
url: apiUrl,
method: 'GET'
method: 'GET',
json: true
};
requestMock.withArgs(repoOptions)
.yieldsAsync(null, fakeResponse, fakeResponse.body);
Expand Down Expand Up @@ -422,11 +427,13 @@ describe('index', () => {
const selfLink = 'https://bitbucket.org/batman/test/commits/40171b678527';
const repoOptions = {
url: repoUrl,
method: 'GET'
method: 'GET',
json: true
};
const authorOptions = {
url: authorUrl,
method: 'GET'
method: 'GET',
json: true
};
let fakeResponse;
let fakeAuthorResponse;
Expand Down Expand Up @@ -541,7 +548,8 @@ describe('index', () => {
const scmUri = 'bitbucket.org:batman/{1234}:mybranch';
const expectedOptions = {
url: apiUrl,
method: 'GET'
method: 'GET',
json: true
};
let fakeResponse;

Expand Down Expand Up @@ -620,7 +628,8 @@ describe('index', () => {
};
const expectedOptions = {
url: apiUrl,
method: 'GET'
method: 'GET',
json: true
};
let fakeResponse;

Expand Down Expand Up @@ -682,15 +691,18 @@ describe('index', () => {
describe('getPermissions', () => {
const pull = {
url: `${API_URL_V2}/repositories/batman?access_key=${token}`,
method: 'GET'
method: 'GET',
json: true
};
const push = {
url: `${API_URL_V2}/repositories/batman?role=contributor&access_key=${token}`,
method: 'GET'
method: 'GET',
json: true
};
const admin = {
url: `${API_URL_V2}/repositories/batman?role=admin&access_key=${token}`,
method: 'GET'
method: 'GET',
json: true
};
const readResponse = {
statusCode: 200,
Expand Down

0 comments on commit ecfba30

Please sign in to comment.