Skip to content

Commit

Permalink
Change tests to catch
Browse files Browse the repository at this point in the history
  • Loading branch information
eablack committed Apr 30, 2024
1 parent 14b95d9 commit 1080b25
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/cli/test/unit/commands/pg/copy.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ describe('pg:copy', function () {
})
it('fails to copy', async function () {
const err = 'An error occurred and the backup did not finish.\n\nfoobar\n\nRun \u001B[36m\u001B[1mheroku pg:backups:info b001\u001B[22m\u001B[39m for more details.'
await expect(runCommand(Cmd, [
await runCommand(Cmd, [
'--app',
'myapp',
'--confirm',
'myapp',
'postgres://foo.com/bar',
'HEROKU_POSTGRESQL_RED_URL',
])).to.throw(Error, err)
]).catch(error => expect(error.message).to.contain(err))
expect(stdout.output).to.equal('')
expect(stderr.output).to.equal(`Starting copy of database bar on foo.com:5432 to RED...\nStarting copy of database bar on foo.com:5432 to RED... done\n${copyingFailText()}`)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('pg:credentials:create', function () {
return expect(stderr.output).to.equal('Creating credential credname...\nCreating credential credname... done\n')
})

it('throws an error when the db is numbered essential plan', function () {
it('throws an error when the db is numbered essential plan', async function () {
const essentialAddon = {
name: 'postgres-1', plan: {name: 'heroku-postgresql:essential-0'},
}
Expand All @@ -53,15 +53,15 @@ describe('pg:credentials:create', function () {
}).reply(200, [{addon: essentialAddon}])

const err = "You can't create a custom credential on Essential-tier databases."
return expect(runCommand(Cmd, [
await runCommand(Cmd, [
'--app',
'myapp',
'--name',
'jeff',
])).to.throw(Error, err)
]).catch(error => expect(error.message).to.contain(err))
})

it('throws an error when the db is essential plan', function () {
it('throws an error when the db is essential plan', async function () {
const hobbyAddon = {
name: 'postgres-1', plan: {name: 'heroku-postgresql:mini'},
}
Expand All @@ -72,11 +72,11 @@ describe('pg:credentials:create', function () {
}).reply(200, [{addon: hobbyAddon}])

const err = "You can't create a custom credential on Essential-tier databases."
return expect(runCommand(Cmd, [
await runCommand(Cmd, [
'--app',
'myapp',
'--name',
'jeff',
])).to.throw(Error, err)
]).catch(error => expect(error.message).to.contain(err))
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ describe('pg:credentials:rotate', function () {
The following error occurred:
--name=my_role cannot also be provided when using --all
See more help with --help`)
return expect(runCommand(Cmd, [
await runCommand(Cmd, [
'--app',
'myapp',
'--all',
'--name',
'my_role',
'--confirm',
'myapp',
])).to.throw(Error, err)
]).catch(error => expect(error.message).to.contain(err))
})

it('requires app confirmation for rotating all roles with --all', async function () {
Expand Down Expand Up @@ -219,12 +219,12 @@ describe('pg:credentials:rotate', function () {
}).reply(200, [{addon: hobbyAddon}])

const err = 'Legacy Essential-tier databases do not support named credentials.'
return expect(runCommand(Cmd, [
await runCommand(Cmd, [
'--app',
'myapp',
'--name',
'jeff',
])).to.throw(Error, err)
]).catch(error => expect(error.message).to.contain(err))
})

it('rotates credentials when the db is numbered essential plan', async function () {
Expand Down
4 changes: 2 additions & 2 deletions packages/oauth-v5/test/unit/clients/update.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('clients:update', () => {
})

it('does nothing with no changes', () => {
return expect(cmd.run({args: {id: 'f6e8d969-129f-42d2-854b-c2eca9d5a42e'}, flags: {}}))
.to.throw(Error, 'No changes provided.')
return cmd.run({args: {id: 'f6e8d969-129f-42d2-854b-c2eca9d5a42e'}, flags: {}})
.catch(error => expect(error.message).to.contain('No changes provided.'))
})
})

0 comments on commit 1080b25

Please sign in to comment.