Skip to content

Commit

Permalink
fix: octokit.repos.replaceTopics is now `octokit.repos.replaceAllTo…
Browse files Browse the repository at this point in the history
…pics` (#386)
  • Loading branch information
gr2m committed Dec 13, 2020
1 parent 26cd77e commit 538bf5b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/branches.js
Expand Up @@ -15,7 +15,7 @@ module.exports = class Branches {
const params = Object.assign(this.repo, { branch: branch.name })

if (this.isEmpty(branch.protection)) {
return this.github.repos.removeBranchProtection(params)
return this.github.repos.deleteBranchProtection(params)
} else {
Object.assign(params, branch.protection, { headers: previewHeaders })
return this.github.repos.updateBranchProtection(params)
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/repository.js
Expand Up @@ -51,7 +51,7 @@ module.exports = class Repository {
return this.github.repos.update(this.settings)
.then(() => {
if (this.topics) {
return this.github.repos.replaceTopics({
return this.github.repos.replaceAllTopics({
owner: this.settings.owner,
repo: this.settings.repo,
names: this.topics.split(/\s*,\s*/),
Expand Down
16 changes: 8 additions & 8 deletions test/unit/lib/plugins/branches.test.js
Expand Up @@ -12,7 +12,7 @@ describe('Branches', () => {
github = {
repos: {
updateBranchProtection: jest.fn().mockImplementation(() => Promise.resolve('updateBranchProtection')),
removeBranchProtection: jest.fn().mockImplementation(() => Promise.resolve('removeBranchProtection'))
deleteBranchProtection: jest.fn().mockImplementation(() => Promise.resolve('deleteBranchProtection'))
}
}
})
Expand Down Expand Up @@ -64,7 +64,7 @@ describe('Branches', () => {

return plugin.sync().then(() => {
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
expect(github.repos.removeBranchProtection).toHaveBeenCalledWith({
expect(github.repos.deleteBranchProtection).toHaveBeenCalledWith({
owner: 'bkeepers',
repo: 'test',
branch: 'master'
Expand All @@ -84,7 +84,7 @@ describe('Branches', () => {

return plugin.sync().then(() => {
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
expect(github.repos.removeBranchProtection).toHaveBeenCalledWith({
expect(github.repos.deleteBranchProtection).toHaveBeenCalledWith({
owner: 'bkeepers',
repo: 'test',
branch: 'master'
Expand All @@ -104,7 +104,7 @@ describe('Branches', () => {

return plugin.sync().then(() => {
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
expect(github.repos.removeBranchProtection).toHaveBeenCalledWith({
expect(github.repos.deleteBranchProtection).toHaveBeenCalledWith({
owner: 'bkeepers',
repo: 'test',
branch: 'master'
Expand All @@ -124,7 +124,7 @@ describe('Branches', () => {

return plugin.sync().then(() => {
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
expect(github.repos.removeBranchProtection).toHaveBeenCalledWith({
expect(github.repos.deleteBranchProtection).toHaveBeenCalledWith({
owner: 'bkeepers',
repo: 'test',
branch: 'master'
Expand All @@ -143,7 +143,7 @@ describe('Branches', () => {

return plugin.sync().then(() => {
expect(github.repos.updateBranchProtection).not.toHaveBeenCalled()
expect(github.repos.removeBranchProtection).not.toHaveBeenCalled()
expect(github.repos.deleteBranchProtection).not.toHaveBeenCalled()
})
})
})
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('Branches', () => {
expect(result[0]).toBe('updateBranchProtection')
})
})
it('returns removeBranchProtection Promise', () => {
it('returns deleteBranchProtection Promise', () => {
const plugin = configure(
[{
name: 'master',
Expand All @@ -202,7 +202,7 @@ describe('Branches', () => {

return plugin.sync().then(result => {
expect(result.length).toBe(1)
expect(result[0]).toBe('removeBranchProtection')
expect(result[0]).toBe('deleteBranchProtection')
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions test/unit/lib/plugins/repository.test.js
Expand Up @@ -12,7 +12,7 @@ describe('Repository', () => {
repos: {
get: jest.fn().mockImplementation(() => Promise.resolve({})),
update: jest.fn().mockImplementation(() => Promise.resolve()),
replaceTopics: jest.fn().mockImplementation(() => Promise.resolve()),
replaceAllTopics: jest.fn().mockImplementation(() => Promise.resolve()),
enableVulnerabilityAlerts: jest.fn().mockImplementation(() => Promise.resolve()),
disableVulnerabilityAlerts: jest.fn().mockImplementation(() => Promise.resolve()),
enableAutomatedSecurityFixes: jest.fn().mockImplementation(() => Promise.resolve()),
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('Repository', () => {
})

return plugin.sync().then(() => {
expect(github.repos.replaceTopics).toHaveBeenCalledWith({
expect(github.repos.replaceAllTopics).toHaveBeenCalledWith({
owner: 'bkeepers',
repo: 'test',
names: ['foo', 'bar'],
Expand Down

0 comments on commit 538bf5b

Please sign in to comment.