mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
fix(config) configManager: totally move away from singletone
This commit is contained in:
parent
2abe7d688d
commit
b6ed7da0a7
16 changed files with 127 additions and 115 deletions
|
|
@ -4,7 +4,7 @@ const test = require('supertape');
|
|||
const io = require('socket.io-client');
|
||||
|
||||
const {connect} = require('../../test/before');
|
||||
const config = require('../config');
|
||||
const config = require('../config').createConfig();
|
||||
|
||||
test('distribute: export', async (t) => {
|
||||
const defaultConfig = {
|
||||
|
|
@ -17,6 +17,7 @@ test('distribute: export', async (t) => {
|
|||
|
||||
const {port, done} = await connect({
|
||||
config: defaultConfig,
|
||||
configManager: config,
|
||||
});
|
||||
|
||||
const url = `http://localhost:${port}/distribute?port=${1111}`;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ test('distribute: import: received: no error', async (t) => {
|
|||
});
|
||||
|
||||
test('distribute: import: received', async (t) => {
|
||||
const configManager = createConfigManager();
|
||||
const {done, port} = await connect({
|
||||
configManager,
|
||||
config: {
|
||||
name: 'bill',
|
||||
import: true,
|
||||
|
|
@ -62,10 +64,9 @@ test('distribute: import: received', async (t) => {
|
|||
},
|
||||
});
|
||||
|
||||
const config = createConfigManager();
|
||||
config('importUrl', `http://localhost:${port}`);
|
||||
configManager('importUrl', `http://localhost:${port}`);
|
||||
|
||||
const {status} = await distribute.import(config);
|
||||
const {status} = await distribute.import(configManager);
|
||||
await done();
|
||||
|
||||
t.equal(status, 'received','should equal');
|
||||
|
|
@ -73,7 +74,9 @@ test('distribute: import: received', async (t) => {
|
|||
});
|
||||
|
||||
test('distribute: import: received: auth: reject', async (t) => {
|
||||
const configManager = createConfigManager();
|
||||
const {done, port} = await connect({
|
||||
configManager,
|
||||
config: {
|
||||
name: 'bill',
|
||||
import: true,
|
||||
|
|
@ -85,10 +88,9 @@ test('distribute: import: received: auth: reject', async (t) => {
|
|||
},
|
||||
});
|
||||
|
||||
const config = createConfigManager();
|
||||
config('importUrl', `http://localhost:${port}`);
|
||||
configManager('importUrl', `http://localhost:${port}`);
|
||||
|
||||
const {status} = await distribute.import(config);
|
||||
const {status} = await distribute.import(configManager);
|
||||
await done();
|
||||
|
||||
t.equal(status, 'reject', 'should equal');
|
||||
|
|
@ -96,7 +98,9 @@ test('distribute: import: received: auth: reject', async (t) => {
|
|||
});
|
||||
|
||||
test('distribute: import: received: auth: accept', async (t) => {
|
||||
const configManager = createConfigManager();
|
||||
const {done, port} = await connect({
|
||||
configManager,
|
||||
config: {
|
||||
name: 'bill',
|
||||
import: true,
|
||||
|
|
@ -108,10 +112,9 @@ test('distribute: import: received: auth: accept', async (t) => {
|
|||
},
|
||||
});
|
||||
|
||||
const config = createConfigManager();
|
||||
config('importUrl', `http://localhost:${port}`);
|
||||
configManager('importUrl', `http://localhost:${port}`);
|
||||
|
||||
const {status} = await distribute.import(config);
|
||||
const {status} = await distribute.import(configManager);
|
||||
await done();
|
||||
|
||||
t.equal(status, 'received','should equal');
|
||||
|
|
@ -119,7 +122,9 @@ test('distribute: import: received: auth: accept', async (t) => {
|
|||
});
|
||||
|
||||
test('distribute: import: received: no name', async (t) => {
|
||||
const configManager = createConfigManager();
|
||||
const {done, port} = await connect({
|
||||
configManager,
|
||||
config: {
|
||||
name: '',
|
||||
import: true,
|
||||
|
|
@ -129,10 +134,9 @@ test('distribute: import: received: no name', async (t) => {
|
|||
},
|
||||
});
|
||||
|
||||
const config = createConfigManager();
|
||||
config('importUrl', `http://localhost:${port}`);
|
||||
configManager('importUrl', `http://localhost:${port}`);
|
||||
|
||||
const {status} = await distribute.import(config);
|
||||
const {status} = await distribute.import(configManager);
|
||||
await done();
|
||||
|
||||
t.equal(status, 'received','should equal');
|
||||
|
|
@ -140,7 +144,9 @@ test('distribute: import: received: no name', async (t) => {
|
|||
});
|
||||
|
||||
test('distribute: import: error', async (t) => {
|
||||
const configManager = createConfigManager();
|
||||
const {done} = await connect({
|
||||
configManager,
|
||||
config: {
|
||||
import: true,
|
||||
export: false,
|
||||
|
|
@ -149,10 +155,9 @@ test('distribute: import: error', async (t) => {
|
|||
},
|
||||
});
|
||||
|
||||
const config = createConfigManager();
|
||||
config('importUrl', `http://localhost:0`);
|
||||
configManager('importUrl', `http://localhost:0`);
|
||||
|
||||
const {status} = await distribute.import(config, {
|
||||
const {status} = await distribute.import(configManager, {
|
||||
reconnection: false,
|
||||
});
|
||||
|
||||
|
|
@ -163,7 +168,9 @@ test('distribute: import: error', async (t) => {
|
|||
});
|
||||
|
||||
test('distribute: import: config:change: no export', async (t) => {
|
||||
const configManager = createConfigManager();
|
||||
const {done} = await connect({
|
||||
configManager,
|
||||
config: {
|
||||
import: true,
|
||||
export: false,
|
||||
|
|
@ -172,9 +179,7 @@ test('distribute: import: config:change: no export', async (t) => {
|
|||
},
|
||||
});
|
||||
|
||||
const config = createConfigManager();
|
||||
|
||||
const {status} = await distribute.import(config, {
|
||||
const {status} = await distribute.import(configManager, {
|
||||
reconnection: false,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
const test = require('supertape');
|
||||
const log = require('./log');
|
||||
const config = require('../config');
|
||||
const {createConfig} = require('../config');
|
||||
|
||||
test('distribute: log: getMessage', (t) => {
|
||||
const e = 'hello';
|
||||
|
|
@ -23,7 +23,9 @@ test('distribute: log: getMessage: message', (t) => {
|
|||
});
|
||||
|
||||
test('distribute: log: config', (t) => {
|
||||
const config = createConfig();
|
||||
const logOriginal = config('log');
|
||||
|
||||
config('log', true);
|
||||
log('log', 'test message');
|
||||
config('log', logOriginal);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue