Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jannyHou committed Nov 13, 2019
1 parent 14de841 commit e7312cc
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions docker.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@

const _ = require('lodash');
const async = require('async');
const spawn = require('child_process').spawn;
const docker = new require('dockerode')();
const fmt = require('util').format;
const http = require('http');
const ms = require('ms');
const fs = require('fs-extra');

// we don't pass any node flags, so we can call _mocha instead the wrapper
const mochaBin = require.resolve('mocha/bin/_mocha');

process.env.CLOUDANT_DATABASE = 'test-db';
process.env.CLOUDANT_PASSWORD = 'pass';
process.env.CLOUDANT_USERNAME = 'admin';
Expand Down Expand Up @@ -45,7 +40,7 @@ async.waterfall([
if (testErr) {
console.error('error running tests:', testErr);
process.exit(1);
};
}
});

function sleep(n) {
Expand Down Expand Up @@ -204,7 +199,7 @@ function createDB(db) {

function listUser() {
return function printUsers(container, next) {
const path = '/_node/[email protected]/_config/admins'
const path = '/_node/[email protected]/_config/admins';
const opts = {
method: 'GET',
path: path,
Expand Down Expand Up @@ -238,27 +233,16 @@ function listUser() {

function exportENV() {
return function createENVFile(container, next) {
const content = "export CLOUDANT_DATABASE='" + process.env.CLOUDANT_DATABASE + "'\n"
+ "export CLOUDANT_USERNAME='" + process.env.CLOUDANT_USERNAME + "'\n"
+ "export CLOUDANT_PASSWORD='" + process.env.CLOUDANT_PASSWORD + "'\n"
+ "export CLOUDANT_PORT=" + process.env.CLOUDANT_PORT + "\n"
+ "export CLOUDANT_HOST='" + process.env.CLOUDANT_HOST + "'";
const content = "export CLOUDANT_URL='" + process.env.CLOUDANT_URL + "'\n" +
"export CLOUDANT_DATABASE='" + process.env.CLOUDANT_DATABASE + "'\n" +
"export CLOUDANT_USER='" + process.env.CLOUDANT_USERNAME + "'\n" +
"export CLOUDANT_PASSWORD='" + process.env.CLOUDANT_PASSWORD + "'\n" +
'export CLOUDANT_PORT=' + process.env.CLOUDANT_PORT + '\n' +
"export CLOUDANT_HOST='" + process.env.CLOUDANT_HOST + "'";
console.log('current directory: ' + __dirname);
fs.writeFileSync('cloudant-config.sh', content, 'utf8');
next();
}
}

// clean up any previous containers
function dockerCleanup(next) {
if (containerToDelete) {
console.log('cleaning up container: %s', containerToDelete.id);
containerToDelete.remove({force: true}, function(err) {
next(err);
});
} else {
setImmediate(next);
}
};
}

// A Writable Stream that just consumes a stream. Useful for draining readable
Expand Down

0 comments on commit e7312cc

Please sign in to comment.