Skip to content

Commit

Permalink
change error msg; rename branchA to base and branchB to head
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulaBarszcz committed Sep 15, 2022
1 parent a8fa356 commit 730fd1e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
15 changes: 7 additions & 8 deletions services/github/github-commits-difference.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { documentation, errorMessagesFor } from './github-helpers.js'
const schema = Joi.object({ total_commits: nonNegativeInteger }).required()

const queryParamSchema = Joi.object({
branchA: Joi.string().required(),
branchB: Joi.string().required(),
base: Joi.string().required(),
head: Joi.string().required(),
}).required()

export default class GithubCommitsDifference extends GithubAuthV3Service {
Expand All @@ -27,8 +27,8 @@ export default class GithubCommitsDifference extends GithubAuthV3Service {
repo: 'vscode',
},
queryParams: {
branchA: '1.60.0',
branchB: '82f2db7',
base: '1.60.0',
head: '82f2db7',
},
staticPreview: this.render({
commitCount: 9227,
Expand All @@ -46,12 +46,11 @@ export default class GithubCommitsDifference extends GithubAuthV3Service {
}
}

async handle({ user, repo }, { branchA, branchB }) {
const notFoundMessage =
'could not establish commit difference between branches/tags/commits'
async handle({ user, repo }, { base, head }) {
const notFoundMessage = 'could not establish commit difference between refs'
const { total_commits: commitCount } = await this._requestJson({
schema,
url: `/repos/${user}/${repo}/compare/${branchA}...${branchB}`,
url: `/repos/${user}/${repo}/compare/${base}...${head}`,
errorMessages: errorMessagesFor(notFoundMessage),
})

Expand Down
17 changes: 8 additions & 9 deletions services/github/github-commits-difference.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,41 @@ import { createServiceTester } from '../tester.js'
export const t = await createServiceTester()

t.create('Commits difference - correct, between branches')
.get('/microsoft/vscode.json?branchA=standalone/0.1.x&branchB=release/1.21')
.get('/microsoft/vscode.json?base=standalone/0.1.x&head=release/1.21')
.expectBadge({
label: 'commits difference',
message: isMetric,
color: 'blue',
})

t.create('Commits difference - correct, between tags')
.get('/microsoft/vscode.json?branchA=1.58.0&branchB=1.59.0')
.get('/microsoft/vscode.json?base=1.58.0&head=1.59.0')
.expectBadge({
label: 'commits difference',
message: isMetric,
color: 'blue',
})

t.create('Commits difference - correct, between commits')
.get('/microsoft/vscode.json?branchA=3d82ef7&branchB=82f2db7')
.get('/microsoft/vscode.json?base=3d82ef7&head=82f2db7')
.expectBadge({
label: 'commits difference',
message: isMetric,
color: 'blue',
})

t.create('Commits difference - incorrect, between commits')
.get('/microsoft/vscode.json?branchA=fffffff&branchB=82f2db7')
.get('/microsoft/vscode.json?base=fffffff&head=82f2db7')
.expectBadge({
label: 'commits difference',
message:
'could not establish commit difference between branches/tags/commits',
message: 'could not establish commit difference between refs',
color: 'red',
})

t.create('Commits difference - incorrect, missing branchB')
.get('/microsoft/vscode.json?branchA=fffffff')
t.create('Commits difference - incorrect, missing head')
.get('/microsoft/vscode.json?base=fffffff')
.expectBadge({
label: 'commits difference',
message: 'invalid query parameter: branchB',
message: 'invalid query parameter: head',
color: 'red',
})

0 comments on commit 730fd1e

Please sign in to comment.