generated from bitprj/Intro-To-Serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.1.4.js
44 lines (34 loc) · 1.28 KB
/
test.1.4.js
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
35
36
37
38
39
40
41
42
43
44
let uri;
const fetch = require('node-fetch');
const args = require('minimist')(process.argv.slice(2))
const functions = require('./functions');
const user = args['user'];
const repo = args['repo'];
async function main() {
uri = process.env.HACKERVOICE_ENDPOINT;
try {
functions.checkSecret(uri, "HACKERVOICE_ENDPOINT")
const commit_file = ['hackervoice/index.js']
functions.checkCommit(commit_file)
uri = functions.queryString(uri)
test1 = "fifiiscool";
uri1 = uri + "&password=" + test1;
const resp = await fetch(uri1, {
method: 'GET'
});
var data = await resp.text()
functions.validateResponseStatus(resp, uri)
if (data == test1) {
console.log("Yay! 🎉 We got: " + JSON.stringify(data) + ", which matches our input.")
} else {
console.error("We got this " + JSON.stringify(data) + ". We should have gotten our input, 'fifiiscool' ... Try again!")
await functions.throwError("We got this " + JSON.stringify(data) + ". We should have gotten our input, 'fifiiscool' ... Try again!", user, repo)
process.exit(1)
}
}
catch (e) {
console.error(e);
await functions.throwError(e, user, repo)
}
}
main();