mirror of
https://github.com/Netflix/dial-reference.git
synced 2026-06-10 03:39:57 +00:00
Add to and improve upon the DIAL server unit tests.
This commit is contained in:
@@ -142,6 +142,40 @@ function launchApplication(host, app, payload) {
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* send HTTP request to the host.
|
||||
*
|
||||
* @param {String} host IP address of host on which DIAL server
|
||||
* @param {String} method HTTP method.
|
||||
* @param {Object} headers HTTP headers, passed as {"Header": Value}
|
||||
* @param {String} urlSuffix appended to the URL
|
||||
* @param {String} body HTTP body
|
||||
*/
|
||||
function sendRequest(host, method, headers, urlSuffix, body) {
|
||||
urlSuffix = urlSuffix || "";
|
||||
|
||||
return new Q()
|
||||
.then(getAppsUrl.bind(null, host))
|
||||
.then(function (appUrl) {
|
||||
var request = {
|
||||
url: encodeURI(appUrl + urlSuffix),
|
||||
method: method,
|
||||
timeout: 6000,
|
||||
headers: headers
|
||||
};
|
||||
request.body = body;
|
||||
return new Q.Promise(function (resolve, reject) {
|
||||
return httpRequest(request, function handleResponse(error, response) {
|
||||
if(error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function sleepSystem(host, key) {
|
||||
var keyComponent = key ? `&key=${key}` : '';
|
||||
return getAppsUrl(host)
|
||||
@@ -279,7 +313,7 @@ function constructAppResourceUrl(host, appName) {
|
||||
return new Q()
|
||||
.then(getAppsUrl.bind(null, host))
|
||||
.then(function (appUrl) {
|
||||
return appUrl.replace(/\/+$/, `/${appName}`);
|
||||
return appUrl.replace(/\/*$/, `/${appName}`);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -423,4 +457,5 @@ module.exports.hideApplicationInstance = hideApplicationInstance;
|
||||
module.exports.constructAppResourceUrl = constructAppResourceUrl;
|
||||
module.exports.getAppsUrl = getAppsUrl;
|
||||
module.exports.getLocation = getLocation;
|
||||
module.exports.sleepSystem = sleepSystem;
|
||||
module.exports.sleepSystem = sleepSystem;
|
||||
module.exports.sendRequest = sendRequest;
|
||||
|
||||
Reference in New Issue
Block a user