-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
108 lines (94 loc) · 2.37 KB
/
test.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const assert = require("chai").assert;
const dockerManager = require("@socialtables/docker-manager");
const mlog = require("mocha-logger");
const req = require("request-promise");
var redis = require("redis");
let client = null;
const COMPOSE_TIMEOUT = 120000;
describe("Integration tests for architecture: ", function() {
before(function() {
this.timeout(COMPOSE_TIMEOUT);
mlog.pending("Spinning up docker compose architecture...");
return dockerManager.composeUp(__dirname, { }, { "to": COMPOSE_TIMEOUT-1000 })
.then(function() {
mlog.success("Done spinning up! Ready to test.");
});
});
it("time server should be up", () => {
var options = {
method: "GET",
uri: "http://localhost:3000/health",
resolveWithFullResponse: true
};
return req(options)
.then(res => {
assert(res.statusCode == 200);
});
});
it("weather server should be up", () => {
var options = {
method: "GET",
uri: "http://localhost:3001/health",
resolveWithFullResponse: true
};
return req(options)
.then(res => {
assert(res.statusCode == 200);
});
});
describe("test the weather server", function() {
it("should respond with the current dc weather", () => {
var options = {
method: "GET",
uri: "http://localhost:3001/",
resolveWithFullResponse: true
};
return req(options)
.then(res => {
assert(res.statusCode == 200);
assert(res.body);
const parsedBody = JSON.parse(res.body);
//console.log("parsedBody: ",parsedBody);
assert(parsedBody);
});
});
});
describe("test that values are being inserted into the cache", function() {
before(function() {
client = redis.createClient({});
});
it("should have the current time in current:dc:time", (done) => {
client.get("current:dc:time", (err, data) => {
if (err) {
done(err);
}
else {
assert(data);
done();
}
});
});
it("should have the current weather in current:dc:weather", (done) => {
client.get("current:dc:weather", (err, data) => {
if (err) {
done(err);
}
else {
assert(data);
done();
}
});
});
after(function() {
client.quit();
});
});
after(function() {
this.timeout(COMPOSE_TIMEOUT);
mlog.pending("Spinning down docker compose architecture...");
return dockerManager.composeDown(__dirname)
.then(function () {
mlog.log("Done spinning down.");
});
});
});