kui-shell
Version:
This is the monorepo for Kui, the hybrid command-line/GUI electron-based Kubernetes tool
76 lines • 3.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const test_1 = require("@kui-shell/test");
const headless_1 = require("@kui-shell/core/tests/lib/headless");
const utils_1 = require("@kui-shell/plugin-k8s/tests/lib/k8s/utils");
const path_1 = require("path");
const ROOT = path_1.dirname(require.resolve('@kui-shell/plugin-k8s/tests/package.json'));
const synonyms = ['kubectl', 'k'];
const doHeadless = (ctx, impl) => {
before(test_1.Common.before(ctx, { noApp: true }));
synonyms.forEach(kubectl => {
const ns = utils_1.createNS();
const inNamespace = `-n ${ns}`;
it(`should create namespace ${ns} via ${kubectl}`, () => {
return impl
.command(`${kubectl} create namespace ${ns}`, ctx.app)
.then(impl.expectOK(ns))
.catch(test_1.Common.oops(ctx, true));
});
it(`should create sample pod from local file via ${kubectl}`, () => {
return impl
.command(`${kubectl} create -f ${ROOT}/data/k8s/headless/pod.yaml ${inNamespace}`, ctx.app)
.then(impl.expectOK('nginx'))
.catch(test_1.Common.oops(ctx, true));
});
it(`should list the new pod via ${kubectl}`, () => {
return impl
.command(`${kubectl} get pods ${inNamespace}`, ctx.app)
.then(impl.expectOK('nginx'))
.catch(test_1.Common.oops(ctx, true));
});
it(`should get the new pod via ${kubectl}`, () => {
return impl
.command(`${kubectl} get pod nginx ${inNamespace}`, ctx.app)
.then(impl.expectOK('nginx'))
.catch(test_1.Common.oops(ctx, true));
});
it(`should get the new pod as JSON via ${kubectl}`, () => {
return impl
.command(`${kubectl} get pod nginx -o json ${inNamespace}`, ctx.app)
.then(impl.expectOK({
kind: 'Pod',
metadata: {
name: 'nginx'
}
}))
.catch(test_1.Common.oops(ctx, true));
});
it(`should delete the new pod by yaml via ${kubectl}`, () => {
return impl
.command(`${kubectl} delete -f ${ROOT}/data/k8s/headless/pod.yaml ${inNamespace}`, ctx.app)
.then(impl.expectOK('pod "nginx" deleted'))
.then(() => utils_1.waitTillNone('pods', impl, 'nginx', undefined, inNamespace)(ctx.app))
.catch(test_1.Common.oops(ctx, true));
});
it(`should create sample pod from local file via ${kubectl}`, () => {
return impl
.command(`${kubectl} create -f ${ROOT}/data/k8s/headless/pod2.yaml ${inNamespace}`, ctx.app)
.then(impl.expectOK('nginx2'))
.catch(test_1.Common.oops(ctx, true));
});
it(`should delete the namespace ${ns} `, () => {
return impl
.command(`${kubectl} delete namespace ${ns}`, ctx.app)
.then(impl.expectOK(`namespace "${ns}" deleted`))
.catch(test_1.Common.oops(ctx, true));
});
});
};
test_1.Common.localDescribe('headless create pod kubectl kui mode', function () {
doHeadless(this, headless_1.kubectl);
});
test_1.Common.localDescribe('headless create pod bin/kui mode', function () {
doHeadless(this, headless_1.cli);
});
//# sourceMappingURL=headless-create-pod.js.map