2018-08-10 21:10:48 +00:00
|
|
|
import { tap, expect } from '@pushrocks/tapbundle';
|
|
|
|
import path = require('path');
|
|
|
|
|
2019-01-09 13:13:32 +00:00
|
|
|
import { Qenv } from '@pushrocks/qenv';
|
|
|
|
const testQenv = new Qenv('./', './.nogit/');
|
2018-08-10 21:10:48 +00:00
|
|
|
|
2019-01-09 13:13:32 +00:00
|
|
|
import * as smartnginx from '../ts/index';
|
2018-08-10 21:10:48 +00:00
|
|
|
|
|
|
|
let testSmartNginx: smartnginx.SmartNginx;
|
|
|
|
let testNginxZone01: smartnginx.NginxHost;
|
|
|
|
let testNginxZone02: smartnginx.NginxHost;
|
|
|
|
|
|
|
|
tap.test('should create a valid instance of SmartNginx', async () => {
|
2019-01-09 11:15:28 +00:00
|
|
|
testSmartNginx = new smartnginx.SmartNginx({});
|
2018-08-10 21:10:48 +00:00
|
|
|
expect(testSmartNginx).to.be.instanceof(smartnginx.SmartNginx);
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.test(`should produce an instance of NginxConfig`, async () => {
|
|
|
|
testNginxZone01 = new smartnginx.NginxHost(testSmartNginx, {
|
|
|
|
hostName: 'test100.bleu.de',
|
2019-01-09 11:15:28 +00:00
|
|
|
destination: '192.192.192.191',
|
|
|
|
privateKey: 'some private',
|
|
|
|
publicKey: 'some public'
|
2018-08-10 21:10:48 +00:00
|
|
|
});
|
|
|
|
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
|
|
|
|
hostName: 'test102.bleu.de',
|
2019-01-09 11:15:28 +00:00
|
|
|
destination: '192.192.192.192',
|
|
|
|
privateKey: 'some private',
|
|
|
|
publicKey: 'some public'
|
2018-08-10 21:10:48 +00:00
|
|
|
});
|
|
|
|
expect(testNginxZone01).to.be.instanceof(smartnginx.NginxHost);
|
2016-07-06 04:33:31 +00:00
|
|
|
});
|
2018-08-10 21:10:48 +00:00
|
|
|
|
2019-01-17 23:45:29 +00:00
|
|
|
tap.test('.addHostCandidate() should add a zone to NginxConfig Object', async () => {
|
|
|
|
testSmartNginx.addHostCandidate(testNginxZone01);
|
|
|
|
testSmartNginx.addHostCandidate(testNginxZone02);
|
2018-08-10 21:10:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tap.test('.deploy() should deploy a config from an instance', async () => {
|
|
|
|
await testSmartNginx.deploy();
|
|
|
|
});
|
|
|
|
|
2019-01-18 00:33:01 +00:00
|
|
|
tap.test('should not redeploy', async () => {
|
|
|
|
testSmartNginx.addHostCandidate(testNginxZone01);
|
|
|
|
testSmartNginx.addHostCandidate(testNginxZone02);
|
|
|
|
await testSmartNginx.deploy();
|
|
|
|
});
|
|
|
|
|
2018-08-10 21:10:48 +00:00
|
|
|
tap.test('.stop() should end the process', async () => {
|
|
|
|
testSmartNginx.nginxProcess.stop();
|
|
|
|
});
|
|
|
|
|
|
|
|
tap.start();
|