mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add cli tests
This commit is contained in:
@@ -44,6 +44,10 @@ function save() {
|
||||
}
|
||||
fs.writeFileSync(configFile,JSON.stringify(config,null,4));
|
||||
}
|
||||
module.exports = {};
|
||||
module.exports = {
|
||||
unload: function() {
|
||||
config = null;
|
||||
}
|
||||
};
|
||||
module.exports.__defineGetter__('target',function() { load(); return config.target|| "http://localhost:1880" });
|
||||
module.exports.__defineSetter__('target',function(v) { load(); config.target = v; save();});
|
||||
|
@@ -27,7 +27,18 @@ module.exports = function(path, options) {
|
||||
options.headers['content-type'] = 'application/json';
|
||||
}
|
||||
options.url = basePath+path;
|
||||
request(options, function(error,response,body) {
|
||||
|
||||
// Pull out the request function so we can stub it in the tests
|
||||
var requestFunc = request.get;
|
||||
|
||||
if (options.method == 'PUT') {
|
||||
requestFunc = request.put;
|
||||
} else if (options.method == 'POST') {
|
||||
requestFunc = request.post;
|
||||
} else if (options.method == 'DELETE') {
|
||||
requestFunc = request.delete;
|
||||
}
|
||||
requestFunc(options, function(error,response,body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
resolve(JSON.parse(body));
|
||||
} else if (error) {
|
||||
|
Reference in New Issue
Block a user