Skip to content

Commit

Permalink
Remove try/catch & update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zwhitfield3 committed Sep 19, 2024
1 parent a6e4b03 commit bcc1c53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
12 changes: 3 additions & 9 deletions src/commands/ai/models/list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {ux} from '@oclif/core'
import {ModelList} from '../../../lib/ai/types'
import {CLIError} from '@oclif/core/lib/errors'
import Command from '../../../lib/base'

const displayModels = (models: ModelList) => {
Expand Down Expand Up @@ -30,13 +29,8 @@ export default class List extends Command {
const herokuAIClient = this.herokuAI
const urlPath = '/available-models'

try {
const {body: availableModels} = await herokuAIClient.get<ModelList>(urlPath)
displayModels(availableModels)
ux.log('\nSee https://devcenter.heroku.com/articles/rainbow-unicorn-princess-models for more info.')
} catch (error) {
const {message} = error as CLIError
ux.error(message, {exit: 1})
}
const {body: availableModels} = await herokuAIClient.get<ModelList>(urlPath)
displayModels(availableModels)
ux.log('\nSee https://devcenter.heroku.com/articles/rainbow-unicorn-princess-models for more info.')
}
}
3 changes: 1 addition & 2 deletions test/commands/ai/models/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ describe('ai:models:list', function () {
try {
await runCommand(Cmd)
} catch (error) {
const {message, oclif} = error as CLIError
const {message} = error as CLIError
expect(stripAnsi(message)).to.contains('Failed to retrieve the list of available models.')
expect(stripAnsi(message)).to.contains(statusURL)
expect(stripAnsi(message)).to.contains(modelsDevCenterURL)
expect(oclif.exit).to.equal(1)
}
})
})

0 comments on commit bcc1c53

Please sign in to comment.