forked from tudvari/docker-composer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.js
202 lines (171 loc) · 7.35 KB
/
tests.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
'use strict';
let composer = require('./');
let fs = require('fs');
let mocha = require('mocha');
let should = require('should');
describe('composer', function() {
it('test all parameters with 2 service', function(done) {
let outputYML = fs.readFileSync('./tests/1_output.yml');
composer.generate(fs.readFileSync('./tests/1_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('test all parameters with 2 service nok', function(done) {
let outputYML = fs.readFileSync('./tests/2_output.yml');
composer.generate(fs.readFileSync('./tests/2_input.json'), function(err, result) {
should.not.exist(err) ;
should.notEqual(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('ports missing', function(done) {
let outputYML = fs.readFileSync('./tests/3_output.yml');
composer.generate(fs.readFileSync('./tests/3_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('ports missing value', function(done) {
let outputYML = fs.readFileSync('./tests/8_output.yml');
composer.generate(fs.readFileSync('./tests/8_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('environment missing value', function(done) {
let outputYML = fs.readFileSync('./tests/4_output.yml');
composer.generate(fs.readFileSync('./tests/4_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('environment missing', function(done) {
let outputYML = fs.readFileSync('./tests/5_output.yml');
composer.generate(fs.readFileSync('./tests/5_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('extra_hosts missing', function(done) {
let outputYML = fs.readFileSync('./tests/6_output.yml');
composer.generate(fs.readFileSync('./tests/6_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('extra_hosts missing value', function(done) {
let outputYML = fs.readFileSync('./tests/7_output.yml');
composer.generate(fs.readFileSync('./tests/7_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('input json is missing', function(done) {
composer.generate(null, function(err, result) {
should.equal(err.message, 'json is missing') ;
})
done();
});
it('environment json is invalid', function(done) {
composer.generate(fs.readFileSync('./tests/9_input.json'), function(err, result) {
should.exists(err) ;
done() ;
}) ;
});
it('expose', function(done) {
let outputYML = fs.readFileSync('./tests/10_output.yml');
composer.generate(fs.readFileSync('./tests/10_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('expose is missing', function(done) {
let outputYML = fs.readFileSync('./tests/11_output.yml');
composer.generate(fs.readFileSync('./tests/11_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('command', function(done) {
let outputYML = fs.readFileSync('./tests/12_output.yml');
composer.generate(fs.readFileSync('./tests/12_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('dns', function(done) {
let outputYML = fs.readFileSync('./tests/14_output.yml');
composer.generate(fs.readFileSync('./tests/14_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('dns missing', function(done) {
let outputYML = fs.readFileSync('./tests/15_output.yml');
composer.generate(fs.readFileSync('./tests/15_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('dns_search', function(done) {
let outputYML = fs.readFileSync('./tests/16_output.yml');
composer.generate(fs.readFileSync('./tests/16_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('dns_search missing', function(done) {
let outputYML = fs.readFileSync('./tests/17_output.yml');
composer.generate(fs.readFileSync('./tests/17_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('mem_limit', function(done) {
let outputYML = fs.readFileSync('./tests/mem_limit_1.yml');
composer.generate(fs.readFileSync('./tests/mem_limit_1.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('memswap_limit', function(done) {
let outputYML = fs.readFileSync('./tests/memswap_limit_1.yml');
composer.generate(fs.readFileSync('./tests/memswap_limit_1.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('cpu_shares', function(done) {
let outputYML = fs.readFileSync('./tests/cpu_shares_output_1.yml');
composer.generate(fs.readFileSync('./tests/cpu_shares_input_1.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
it('custom appends (net, links, entrypoint, volumes, restart)', function(done) {
let outputYML = fs.readFileSync('./tests/custom_net_output.yml');
composer.generate(fs.readFileSync('./tests/custom_net_input.json'), function(err, result) {
should.not.exist(err) ;
should.equal(result.replace(/(\r\n|\n|\r)/gm, ""), outputYML.toString().replace(/(\r\n|\n|\r)/gm, "")) ;
});
done() ;
}) ;
});