fix dockerproxy test
This commit is contained in:
@@ -7,10 +7,13 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
const child_process = require('child_process'),
|
||||
common = require('./common.js'),
|
||||
constants = require('../constants.js'),
|
||||
dockerProxy = require('../dockerproxy.js'),
|
||||
expect = require('expect.js');
|
||||
expect = require('expect.js'),
|
||||
infra = require('../infra_version.js');
|
||||
|
||||
const DOCKER = `docker -H tcp://172.18.0.1:${constants.DOCKER_PROXY_PORT} `;
|
||||
|
||||
@@ -26,18 +29,21 @@ async function exec(cmd) {
|
||||
|
||||
describe('Dockerproxy', function () {
|
||||
let containerId;
|
||||
const { setup, cleanup } = common;
|
||||
|
||||
// create a container to test against
|
||||
before(async function () {
|
||||
await setup();
|
||||
await dockerProxy.start();
|
||||
|
||||
const stdout = await exec(`${DOCKER} run -d cloudron/base:3.0.0 "bin/bash" "-c" "while true; do echo 'perpetual walrus'; sleep 1; done"`);
|
||||
const stdout = await exec(`${DOCKER} run -d ${infra.images.base} "bin/bash" "-c" "while true; do echo 'perpetual walrus'; sleep 1; done"`);
|
||||
containerId = stdout.slice(0, -1); // removes the trailing \n
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await exec(`${DOCKER} rm -f ${containerId}`);
|
||||
await dockerProxy.stop();
|
||||
await cleanup();
|
||||
});
|
||||
|
||||
// uncomment this to run the proxy for manual testing
|
||||
@@ -50,13 +56,13 @@ describe('Dockerproxy', function () {
|
||||
});
|
||||
|
||||
it('can create container', async function () {
|
||||
const cmd = `${DOCKER} run cloudron/base:3.0.0 "/bin/bash" "-c" "echo 'hello'"`;
|
||||
const cmd = `${DOCKER} run ${infra.images.base} "/bin/bash" "-c" "echo 'hello'"`;
|
||||
const stdout = await exec(cmd);
|
||||
expect(stdout).to.contain('hello');
|
||||
});
|
||||
|
||||
it('proxy overwrites the container network option', async function () {
|
||||
const cmd = `${DOCKER} run --network ifnotrewritethiswouldfail cloudron/base:3.0.0 "/bin/bash" "-c" "echo 'hello'"`;
|
||||
const cmd = `${DOCKER} run --network ifnotrewritethiswouldfail ${infra.images.base} "/bin/bash" "-c" "echo 'hello'"`;
|
||||
const stdout = await exec(cmd);
|
||||
expect(stdout).to.contain('hello');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user