@haechi-labs/henesis-cli
Version:
🚀 Command Line Interface tool to Utilize henesis
66 lines • 2.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const test_1 = require("@oclif/test");
const mock_1 = require("../../mock");
const yaml = tslib_1.__importStar(require("js-yaml"));
const fs = tslib_1.__importStar(require("fs"));
const utils = tslib_1.__importStar(require("../../utils"));
process.env.HENESIS_TEST = 'true';
describe('integration:deploy', () => {
const specPath = './henesis.yaml';
let integrationSpec;
beforeEach('set spec and integration', () => {
integrationSpec = mock_1.newMockIntegrationSpec();
fs.writeFileSync(specPath, yaml.safeDump(integrationSpec));
});
afterEach('set spec and integration', () => {
fs.unlinkSync(specPath);
});
context('deploy spec when no error occurred', async () => {
const res = mock_1.newMockIntegration();
test_1.test
.timeout(10000)
.nock('http://localhost:8080', (api) => api.post('/integrations/v1').reply(200, res))
.stub(utils, 'startWait', () => { })
.stub(utils, 'endWait', () => { })
.stdout()
.command([`integration:deploy`, `--path=${specPath}`])
.it('should deploy a integration', (ctx) => {
test_1.expect(ctx.stdout).to.equal(`${res.integrationId} has been deployed\n`);
});
});
context('deploy spec with default spec path when no error occurred', async () => {
const res = mock_1.newMockIntegration();
test_1.test
.timeout(10000)
.nock('http://localhost:8080', (api) => api.post('/integrations/v1').reply(200, res))
.stub(utils, 'startWait', () => { })
.stub(utils, 'endWait', () => { })
.stdout()
.command([`integration:deploy`])
.it('should deploy a integration with default spec path', (ctx) => {
test_1.expect(ctx.stdout).to.equal(`${res.integrationId} has been deployed\n`);
});
});
context('update spec when no error occurred', async () => {
const res = mock_1.newMockIntegration();
test_1.test
.timeout(10000)
.nock('http://localhost:8080', (api) => {
api
.put(`/integrations/v1/${res.integrationId}`)
.reply(200, res)
.get(`/integrations/v1/findByName?name=${integrationSpec.name}`)
.reply(200, res);
})
.stub(utils, 'startWait', () => { })
.stub(utils, 'endWait', () => { })
.stdout()
.command([`integration:deploy`, `--path=${specPath}`, `-f`])
.it('should deploy a integration with update option', (ctx) => {
test_1.expect(ctx.stdout).to.equal(`${res.integrationId} has been deployed with force\n`);
});
});
});
//# sourceMappingURL=deploy.spec.js.map