smartnginx/test/test.ts

56 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

2023-07-26 14:05:53 +00:00
import { tap, expect } from '@push.rocks/tapbundle';
import path = require('path');
2023-07-26 14:05:53 +00:00
import { Qenv } from '@push.rocks/qenv';
2019-01-09 13:13:32 +00:00
const testQenv = new Qenv('./', './.nogit/');
2023-07-26 14:05:53 +00:00
import * as smartnginx from '../ts/index.js';
let testSmartNginx: smartnginx.SmartNginx;
let testNginxZone01: smartnginx.NginxHost;
let testNginxZone02: smartnginx.NginxHost;
tap.test('should create a valid instance of SmartNginx', async () => {
2019-08-20 20:30:31 +00:00
testSmartNginx = new smartnginx.SmartNginx({ defaultProxyUrl: 'https://git.zone' });
2023-07-26 14:05:53 +00:00
expect(testSmartNginx).toBeInstanceOf(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',
2019-01-19 14:41:51 +00:00
destinationPort: 3000,
2019-01-09 11:15:28 +00:00
privateKey: 'some private',
2023-07-26 14:05:53 +00:00
publicKey: 'some public',
});
testNginxZone02 = new smartnginx.NginxHost(testSmartNginx, {
hostName: 'test102.bleu.de',
2019-01-09 11:15:28 +00:00
destination: '192.192.192.192',
2019-01-19 14:41:51 +00:00
destinationPort: 3050,
2019-01-09 11:15:28 +00:00
privateKey: 'some private',
2023-07-26 14:05:53 +00:00
publicKey: 'some public',
});
2023-07-26 14:05:53 +00:00
expect(testNginxZone01).toBeInstanceOf(smartnginx.NginxHost);
2016-07-06 04:33:31 +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);
});
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();
});
tap.test('.stop() should end the process', async () => {
testSmartNginx.nginxProcess.stop();
});
tap.start();