Skip to content

Commit d1b1aa2

Browse files
authored
Merge pull request #22 from Netflix/2.2
Add NodeJS tests for 2.2 version of spec
2 parents 9bddab3 + 84c3da1 commit d1b1aa2

8 files changed

Lines changed: 1465 additions & 48 deletions

server/tests/js_tests/libs/dialClient.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,31 @@ function launchApplication(host, app, payload) {
142142
});
143143
}
144144

145+
function sleepSystem(host, key) {
146+
var keyComponent = key ? `&key=${key}` : '';
147+
return getAppsUrl(host)
148+
// TODO: Send friendlyName query parameter for DIAL 2.1 and greater versions of server
149+
.then(function (appsUrl) {
150+
var request = {
151+
url: `${appsUrl}/system?action=sleep${keyComponent}`,
152+
method: "POST",
153+
timeout: 6000,
154+
headers: {
155+
"Content-Type" : "text/plain;charset=\"utf-8\""
156+
}
157+
};
158+
159+
return new Promise(function (resolve, reject) {
160+
return httpRequest(request, function handleResponse(error, response) {
161+
if(!error) {
162+
return resolve(response);
163+
}
164+
return reject(new Error("Error launching application " + error));
165+
});
166+
});
167+
});
168+
}
169+
145170
function stopApplication(host, app) {
146171
return new Q()
147172
.then(constructAppResourceUrl.bind(null, host, app))
@@ -164,9 +189,9 @@ function stopApplication(host, app) {
164189
return new Q.Promise(function (resolve, reject) {
165190
return httpRequest(request, function handleResponse(error, response) {
166191
if(!error) {
167-
return resolve(response);
192+
resolve(response);
168193
}
169-
return reject(new Error("Error stopping application " + error));
194+
reject(new Error("Error stopping application " + error));
170195
});
171196
});
172197
});
@@ -254,7 +279,7 @@ function constructAppResourceUrl(host, appName) {
254279
return new Q()
255280
.then(getAppsUrl.bind(null, host))
256281
.then(function (appUrl) {
257-
return appUrl.replace(/\/+$/, "") + "/" + appName;
282+
return appUrl.replace(/\/+$/, `/${appName}`);
258283
});
259284
}
260285

@@ -273,7 +298,7 @@ function getAppsUrl(host) {
273298
});
274299

275300
if(found) {
276-
return appUrl;
301+
return Promise.resolve(appUrl);
277302
}
278303

279304
// If value is not persisted
@@ -398,3 +423,4 @@ module.exports.hideApplicationInstance = hideApplicationInstance;
398423
module.exports.constructAppResourceUrl = constructAppResourceUrl;
399424
module.exports.getAppsUrl = getAppsUrl;
400425
module.exports.getLocation = getLocation;
426+
module.exports.sleepSystem = sleepSystem;

0 commit comments

Comments
 (0)