tests: complete common'ification of routes tests

This commit is contained in:
Girish Ramakrishnan
2021-08-12 21:24:18 -07:00
parent ac5b7f8093
commit ec0d64ac12
3 changed files with 182 additions and 338 deletions

View File

@@ -16,6 +16,7 @@ const async = require('async'),
exports = module.exports = {
setup,
setupServer,
cleanup,
clearMailQueue,
checkMails,
@@ -25,6 +26,7 @@ exports = module.exports = {
username: 'superadmin',
password: 'Foobar?1337',
email: 'superadmin@cloudron.local',
displayName: 'Super Admin',
token: null
},
@@ -44,17 +46,20 @@ exports = module.exports = {
serverUrl: `http://localhost:${constants.PORT}`,
};
function setupServer(done) {
async.series([
server.start.bind(null),
database._clear.bind(null),
settings._setApiServerOrigin.bind(null, exports.mockApiServerOrigin),
], done);
}
function setup(done) {
const owner = exports.owner, serverUrl = exports.serverUrl, user = exports.user;
async.series([
server.start.bind(null),
database._clear.bind(null),
setupServer,
async () => await safe(fs.promises.unlink(support._sshInfo().filePath)),
settings._setApiServerOrigin.bind(null, exports.mockApiServerOrigin),
settings.setCloudronToken.bind(null, exports.appstoreToken),
function setup(callback) {