-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
34 lines (31 loc) · 767 Bytes
/
Copy pathutils.js
File metadata and controls
34 lines (31 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
var chai = require('chai');
var request = require('request');
var _ = require('lodash');
chai.config.includeStack = true;
module.exports = {
assert: chai.assert,
postToHost: function(host, funcName, opts, cb) {
opts = opts || {};
if (_.isFunction(opts)) {
cb = opts;
opts = {};
}
var url = host.getUrl() + '/function/' + funcName;
if (opts.key) {
url += '?key=' + encodeURIComponent(opts.key);
}
request.post({
url: url,
json: true,
body: opts.data
}, cb);
},
postToManager: function(manager, endpoint, data, cb) {
if (_.isFunction(data)) {
cb = data;
data = {};
}
request.post({url: manager.getUrl() + endpoint, body: data, json: true}, cb);
}
};