From 1b15db85e3b2dc73dca536b306ec26783ae266dd Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Mon, 3 Sep 2018 17:44:23 +0200 Subject: [PATCH] Avoid nxdomain during tests and always specify app id --- test/test.js | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/test/test.js b/test/test.js index ff13750..95591ea 100755 --- a/test/test.js +++ b/test/test.js @@ -234,8 +234,8 @@ return done(); function addCustomFile(done) { fs.writeFileSync('/tmp/customfile.txt', 'GOGS TEST', 'utf8'); - execSync('cloudron exec -- mkdir -p /app/data/custom/public'); - execSync('cloudron push /tmp/customfile.txt /app/data/custom/public/customfile.txt'); + execSync(`cloudron exec --app ${app.id} -- mkdir -p /app/data/custom/public`); + execSync(`cloudron push --app ${app.id} /tmp/customfile.txt /app/data/custom/public/customfile.txt`); fs.unlinkSync('/tmp/customfile.txt'); done(); } @@ -351,12 +351,17 @@ return done(); it('can clone the url', cloneRepo); it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); }); - it('move to different location', function () { + it('move to different location', function (done) { //browser.manage().deleteAllCookies(); // commented because of error "'Network.deleteCookie' wasn't found" - execSync('cloudron configure --wait --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); - var inspect = JSON.parse(execSync('cloudron inspect')); - app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0]; - expect(app).to.be.an('object'); + // ensure we don't hit NXDOMAIN in the mean time + browser.get('about:blank').then(function () { + execSync('cloudron configure --wait --location ' + LOCATION + '2 --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + var inspect = JSON.parse(execSync('cloudron inspect')); + app = inspect.apps.filter(function (a) { return a.location === LOCATION + '2'; })[0]; + expect(app).to.be.an('object'); + + done(); + }); }); it('can login', login); @@ -365,8 +370,12 @@ return done(); it('can clone the url', cloneRepo); it('file exists in repo', function () { expect(fs.existsSync(repodir + '/newfile')).to.be(true); }); - it('uninstall app', function () { - execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + it('uninstall app', function (done) { + // ensure we don't hit NXDOMAIN in the mean time + browser.get('about:blank').then(function () { + execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + done(); + }); }); // check if the _first_ login via email succeeds @@ -379,8 +388,12 @@ return done(); login(function (error) { if (error) return done(error); - execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); - done(); + + // ensure we don't hit NXDOMAIN in the mean time + browser.get('about:blank').then(function () { + execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + done(); + }); }); }); @@ -408,7 +421,11 @@ return done(); it('can clone the url', cloneRepo); it('file exists in cloned repo', fileExists); - it('uninstall app', function () { - execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + it('uninstall app', function (done) { + // ensure we don't hit NXDOMAIN in the mean time + browser.get('about:blank').then(function () { + execSync('cloudron uninstall --app ' + app.id, { cwd: path.resolve(__dirname, '..'), stdio: 'inherit' }); + done(); + }); }); });