node_terminus
Version:
Pantheon Terminus cli wrapper and extensions
98 lines (94 loc) • 4 kB
JavaScript
const expect = require('chai').expect
var common = require('./common');
let NT = common.nt;
const nt = new NT();
function importTest(name,path) {
describe(name, () => {
require(path);
});
}
describe('"Node Terminus" Tests',() => {
it(' * object ----> "nt" has instantiated',() => {
expect(nt).is.a('object')
})
it(' * prop ----> "nt" has "name" equal to "nt"',() => {
expect(nt.name).is.equal('nt')
})
it(` * prop ----> "nt" has "base_path" assigned as: ${nt.config.base_path}`, () => {
expect(nt.config.base_path).is.not.null
})
it(` * prop ----> "nt" has "cache_path" assigned as: ${nt.config.cache_path}`, () => {
expect(nt.config.cache_path).is.not.null
})
it(' * object ----> "nt" has "cli" object',() => {
expect(nt.cli).is.a('object')
})
describe('"base"',() => {
it(' * array ----> "nt" has "base" array',() => {
expect(nt.base).is.a('array')
})
it(' * object ----> "base" has "Base" Class',() => {
expect(nt.base[0]).is.a('function')
})
it(' * object ----> "base" has "Docker" Class',() => {
expect(nt.base[1]).is.a('function')
})
})
describe('Terminus Object:',() => {
it(' * object ----> "nt" has "terminus" object',() => {
expect(nt.terminus).is.a('object')
})
it(` * object ----> "terminus" has a "auth_login" object`,() => {
expect(nt.terminus.cmd.auth_login).is.a('object')
})
it(` * function ----> "auth_login" has a "run" function`,() => {
expect(nt.terminus.cmd.auth_login.run).is.a('function')
})
it(' * array ----> "terminus" has a "cmd" array',() => {
expect(nt.terminus.cmd).is.a('array')
})
it(` * env ----> "terminus" Object has Environment variable.MACHINE_TOKEN `,() => {
expect(nt.config.machine_token).is.a('string').and.is.not.null
})
it(` * env ----> "MACHINE_TOKEN" is defined, then config.machine_token should match`,() => {
if (nt.config.machine_token === process.env.MACHINE_TOKEN) {
expect(true).to.be.equal(true)
} else {
expect(true).is.equal.false
}
})
}
)
describe("Config Object:",() => {
it(` * object ----> "nt" has "config" object`,() => {
expect(nt.config).is.a('object')
})
it(` * prop ----> "config" has a string "base_cmd" '${nt.config.base_cmd}'`,() => {
expect(nt.config.base_cmd).is.a('string').and.is.not.null
})
it(` * prop ----> "config" has a string "docker_image" '${nt.config.docker_image}'`,() => {
expect(nt.config.docker_image).is.a('string').and.is.not.null
})
it(` * prop ----> "config" has a string "docker_host" '${nt.config.docker_host}'`,() => {
expect(nt.config.docker_host).is.a('string').and.is.not.null
})
})
describe('Docker "cli" Tests - Defaults and override check',() => {
it(` * env ----> "nt" Object has Environment variable.DOCKER_HOST `,() => {
expect(process.env.DOCKER_HOST).is.a('string').and.is.not.null
})
it(` * config ----> "nt" nt/libs/utils/configs.js with default "docker_host" assigned as "tcp://localhost:2375"`,() => {
expect(nt.config.docker_host).is.equal('tcp://localhost:2375')
})
it(` * config ----> "nt"."config."docker_host" can override default value, assigned value "testing"`,() => {
nt.config.docker_host="testing"
expect(nt.config.docker_host).is.equal('testing')
})
process.env.DOCKER_HOST = "ENVTEST_OVERRIDE"
it(` * env ----> "nt" Objects Environment can be override with DOCKER_HOST docker_host" assigning value "ENVTEST_OVERRIDE"`,() => {
expect(process.env.DOCKER_HOST).is.equal('ENVTEST_OVERRIDE')
})
})
})
// TODO: Finish up tests, actually verify login, verify docker communications, etc. reimplement tests i've had but stopping to work on othings things.
//importTest('"Pantheon Module" Tests:', './dependencies/pantheon/pantheon.spec.js');