fix(core): update
This commit is contained in:
51
test/test.ts
51
test/test.ts
@ -1,7 +1,6 @@
|
||||
import { tap, expect } from '@pushrocks/tapbundle';
|
||||
import * as path from 'path';
|
||||
|
||||
// Setup test
|
||||
process.env.NPMTS_TEST = 'true';
|
||||
|
||||
// set up environment
|
||||
@ -18,66 +17,66 @@ process.cwd = () => {
|
||||
return path.join(__dirname, 'assets/');
|
||||
};
|
||||
|
||||
// require NPMCI files
|
||||
import '../ts/index';
|
||||
import npmciModDocker = require('../ts/mod_docker/index');
|
||||
import npmciModNpm = require('../ts/mod_npm/index');
|
||||
import npmciModNode = require('../ts/mod_node/index');
|
||||
import npmciModSsh = require('../ts/mod_ssh/index');
|
||||
import npmciEnv = require('../ts/npmci.env');
|
||||
import * as npmci from '../ts';
|
||||
|
||||
// ======
|
||||
// Docker
|
||||
// ======
|
||||
|
||||
let dockerfile1: npmciModDocker.Dockerfile;
|
||||
let dockerfile2: npmciModDocker.Dockerfile;
|
||||
let sortableArray: npmciModDocker.Dockerfile[];
|
||||
let dockerfile1: npmci.Dockerfile;
|
||||
let dockerfile2: npmci.Dockerfile;
|
||||
let sortableArray: npmci.Dockerfile[];
|
||||
|
||||
tap.test('should return valid Dockerfiles', async () => {
|
||||
dockerfile1 = new npmciModDocker.Dockerfile({ filePath: './Dockerfile', read: true });
|
||||
dockerfile2 = new npmciModDocker.Dockerfile({ filePath: './Dockerfile_sometag1', read: true });
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
dockerfile1 = new npmci.Dockerfile(npmciInstance.dockerManager, { filePath: './Dockerfile', read: true });
|
||||
dockerfile2 = new npmci.Dockerfile(npmciInstance.dockerManager, { filePath: './Dockerfile_sometag1', read: true });
|
||||
expect(dockerfile1.version).to.equal('latest');
|
||||
return expect(dockerfile2.version).to.equal('sometag1');
|
||||
});
|
||||
|
||||
tap.test('should read a directory of Dockerfiles', async () => {
|
||||
return npmciModDocker.helpers
|
||||
.readDockerfiles()
|
||||
.then(async (readDockerfilesArrayArg: npmciModDocker.Dockerfile[]) => {
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
return npmci.Dockerfile
|
||||
.readDockerfiles(npmciInstance.dockerManager)
|
||||
.then(async (readDockerfilesArrayArg: npmci.Dockerfile[]) => {
|
||||
sortableArray = readDockerfilesArrayArg;
|
||||
return expect(readDockerfilesArrayArg[1].version).to.equal('sometag1');
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should sort an array of Dockerfiles', async () => {
|
||||
return npmciModDocker.helpers
|
||||
return npmci.Dockerfile
|
||||
.sortDockerfiles(sortableArray)
|
||||
.then(async (sortedArrayArg: npmciModDocker.Dockerfile[]) => {
|
||||
.then(async (sortedArrayArg: npmci.Dockerfile[]) => {
|
||||
console.log(sortedArrayArg);
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should build all Dockerfiles', async () => {
|
||||
return npmciModDocker.handleCli({
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
return npmciInstance.dockerManager.handleCli({
|
||||
_: ['docker', 'build']
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should test all Dockerfiles', async () => {
|
||||
return await npmciModDocker.handleCli({
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
return npmciInstance.dockerManager.handleCli({
|
||||
_: ['docker', 'test']
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should test dockerfiles', async () => {
|
||||
return await npmciModDocker.handleCli({
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
return npmciInstance.dockerManager.handleCli({
|
||||
_: ['docker', 'test']
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should login docker daemon', async () => {
|
||||
return await npmciModDocker.handleCli({
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
return npmciInstance.dockerManager.handleCli({
|
||||
_: ['docker', 'login']
|
||||
});
|
||||
});
|
||||
@ -86,6 +85,7 @@ tap.test('should login docker daemon', async () => {
|
||||
// SSH
|
||||
// ===
|
||||
tap.test('should prepare SSH keys', async () => {
|
||||
const npmciModSsh = await import('../ts/mod_ssh');
|
||||
return await npmciModSsh.handleCli({
|
||||
_: ['ssh', 'prepare']
|
||||
});
|
||||
@ -95,13 +95,14 @@ tap.test('should prepare SSH keys', async () => {
|
||||
// node
|
||||
// ====
|
||||
tap.test('should install a certain version of node', async () => {
|
||||
await npmciModNode.handleCli({
|
||||
const npmciInstance = new npmci.Npmci();
|
||||
await npmciInstance.nodejsManager.handleCli({
|
||||
_: ['node', 'install', 'stable']
|
||||
});
|
||||
await npmciModNode.handleCli({
|
||||
await npmciInstance.nodejsManager.handleCli({
|
||||
_: ['node', 'install', 'lts']
|
||||
});
|
||||
await npmciModNode.handleCli({
|
||||
await npmciInstance.nodejsManager.handleCli({
|
||||
_: ['node', 'install', 'legacy']
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user