UNPKG

1.23 kBJavaScriptView Raw
1'use strict';
2
3const { resolve } = require('path');
4
5const chai = require('chai');
6
7const { execFile } = require('../js/utils');
8
9describe('watchable', function () {
10 const assert = chai.assert;
11 const watchablePath = resolve(__dirname, '../js/watchable.js');
12 const projectDir = resolve(__dirname, 'fixtures/project-a');
13
14 async function watchable(args = [], dcFile, expected) {
15 const { stdout, stderr } = await execFile(watchablePath, args, {
16 cwd: projectDir,
17 env: {
18 ...process.env,
19 COMPOSE_FILE: dcFile
20 }
21 });
22 if (stderr) {
23 console.error(' - stdout:', stdout);
24 throw new Error(stderr);
25 }
26 assert.equal(JSON.parse(stdout), expected, `watchable ${args.join(' ')} should be ${expected}, got ${stdout}.`);
27 }
28
29 it('check services in dc.prod.yml', async () => {
30 const dcFile = 'dc.prod.yml';
31 await watchable(['back-a'], dcFile, 1);
32 await watchable(['back-b'], dcFile, 0);
33 await watchable(['back-c'], dcFile, 1);
34 await watchable(['front-a'], dcFile, 2);
35 await watchable(['watch-b'], dcFile, 0);
36 await watchable(['store-a'], dcFile, 0);
37 await watchable(['ext-a'], dcFile, 0);
38 await watchable(['unknown'], dcFile, 0);
39 });
40
41});