From 975c6c29a703424db51c400bd99796aada320a4d Mon Sep 17 00:00:00 2001 From: Katy Bowman Date: Wed, 25 Sep 2024 13:17:35 -0400 Subject: [PATCH] test: add inital test for ai:models:detach --- test/commands/ai/models/detach.test.ts | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/commands/ai/models/detach.test.ts diff --git a/test/commands/ai/models/detach.test.ts b/test/commands/ai/models/detach.test.ts new file mode 100644 index 0000000..a7a9bec --- /dev/null +++ b/test/commands/ai/models/detach.test.ts @@ -0,0 +1,27 @@ +import {stdout, stderr} from 'stdout-stderr' +import Cmd from '../../../../src/commands/ai/models/detach' +import {runCommand} from '../../../run-command' +import nock from 'nock' +import {expect} from 'chai' + +describe('addons:detach', function () { + afterEach(nock.cleanAll) + + it('detaches an add-on', function () { + const api = nock('https://api.heroku.com:443') + .get('/apps/myapp/addon-attachments/redis-123') + .reply(200, {id: 100, name: 'redis-123', addon: {name: 'redis'}}) + .delete('/addon-attachments/100') + .reply(200) + .get('/apps/myapp/releases') + .reply(200, [{version: 10}]) + + return runCommand(Cmd, ['--app', 'myapp', 'redis-123']) + .then(() => { + expect(stdout.output).to.equal('') + expect(stderr.output).to.contain('Detaching redis-123 to redis from myapp... done\n') + expect(stderr.output).to.contain('Unsetting redis-123 config vars and restarting myapp... done, v10\n') + }) + .then(() => api.done()) + }) +})