Skip to content

Commit

Permalink
Merge pull request #22 from Netflix/2.2
Browse files Browse the repository at this point in the history
Add NodeJS tests for 2.2 version of spec
  • Loading branch information
kemorrisnf committed Oct 29, 2018
2 parents 9bddab3 + 84c3da1 commit d1b1aa2
Show file tree
Hide file tree
Showing 8 changed files with 1,465 additions and 48 deletions.
34 changes: 30 additions & 4 deletions server/tests/js_tests/libs/dialClient.js
Expand Up @@ -142,6 +142,31 @@ function launchApplication(host, app, payload) {
});
}

function sleepSystem(host, key) {
var keyComponent = key ? `&key=${key}` : '';
return getAppsUrl(host)
// TODO: Send friendlyName query parameter for DIAL 2.1 and greater versions of server
.then(function (appsUrl) {
var request = {
url: `${appsUrl}/system?action=sleep${keyComponent}`,
method: "POST",
timeout: 6000,
headers: {
"Content-Type" : "text/plain;charset=\"utf-8\""
}
};

return new Promise(function (resolve, reject) {
return httpRequest(request, function handleResponse(error, response) {
if(!error) {
return resolve(response);
}
return reject(new Error("Error launching application " + error));
});
});
});
}

function stopApplication(host, app) {
return new Q()
.then(constructAppResourceUrl.bind(null, host, app))
Expand All @@ -164,9 +189,9 @@ function stopApplication(host, app) {
return new Q.Promise(function (resolve, reject) {
return httpRequest(request, function handleResponse(error, response) {
if(!error) {
return resolve(response);
resolve(response);
}
return reject(new Error("Error stopping application " + error));
reject(new Error("Error stopping application " + error));
});
});
});
Expand Down Expand Up @@ -254,7 +279,7 @@ function constructAppResourceUrl(host, appName) {
return new Q()
.then(getAppsUrl.bind(null, host))
.then(function (appUrl) {
return appUrl.replace(/\/+$/, "") + "/" + appName;
return appUrl.replace(/\/+$/, `/${appName}`);
});
}

Expand All @@ -273,7 +298,7 @@ function getAppsUrl(host) {
});

if(found) {
return appUrl;
return Promise.resolve(appUrl);
}

// If value is not persisted
Expand Down Expand Up @@ -398,3 +423,4 @@ module.exports.hideApplicationInstance = hideApplicationInstance;
module.exports.constructAppResourceUrl = constructAppResourceUrl;
module.exports.getAppsUrl = getAppsUrl;
module.exports.getLocation = getLocation;
module.exports.sleepSystem = sleepSystem;

0 comments on commit d1b1aa2

Please sign in to comment.