fix getLabel to createLabel pipeline

This commit is contained in:
tbushman
2018-11-18 12:02:26 -07:00
committed by mrugesh mohapatra
parent 8960c082d4
commit e5501000df
2 changed files with 8 additions and 5 deletions

View File

@ -7,6 +7,7 @@ class Presolver {
owner, owner,
repo repo
}) })
// console.log(this.config)
this.pullRequest = {} this.pullRequest = {}
this.conflictingFiles = [] this.conflictingFiles = []
} }
@ -62,12 +63,13 @@ class Presolver {
async _createLabel (labelObj) { async _createLabel (labelObj) {
const { owner, repo } = this.config const { owner, repo } = this.config
const github = this.github
console.log(this.github.issues.getLabel({ owner, repo, name: labelObj.name }))
return this.github.issues return this.github.issues
.getLabels({ owner, repo, name: labelObj.name }) .getLabel({ owner, repo, name: labelObj.name })
.catch(() => { .catch(() => {
// console.log(labelObj) console.log(labelObj)
return this.github.issues.createLabel({ return github.issues.createLabel({
owner, owner,
repo, repo,
name: labelObj.name, name: labelObj.name,
@ -93,6 +95,7 @@ class Presolver {
// Check if a label does not exist. If it does, it addes the label. // Check if a label does not exist. If it does, it addes the label.
return this._getLabel(label).catch(() => { return this._getLabel(label).catch(() => {
// console.log(labelObj)
return this.github.issues.addLabels({ return this.github.issues.addLabels({
owner, owner,
repo, repo,

View File

@ -17,7 +17,7 @@ describe('Presolver', () => {
issues: { issues: {
createComment: jest.fn().mockReturnValue(Promise.resolve({})), createComment: jest.fn().mockReturnValue(Promise.resolve({})),
addLabels: jest.fn(), addLabels: jest.fn(),
getLabels: jest.fn().mockImplementation(() => Promise.resolve([])), getLabel: jest.fn().mockImplementation(() => Promise.resolve([])),
createLabel: jest.fn() createLabel: jest.fn()
}, },
repos: { repos: {