1
1
package config_test
2
2
3
3
import (
4
- "fmt"
5
4
"sort"
6
5
"testing"
7
6
@@ -144,15 +143,14 @@ func TestGenerate(t *testing.T) {
144
143
145
144
files := generator .Generate (conf )
146
145
147
- g .Expect (files ).To (HaveLen (17 ))
146
+ g .Expect (files ).To (HaveLen (16 ))
148
147
arrange := func (i , j int ) bool {
149
148
return files [i ].Path < files [j ].Path
150
149
}
151
150
sort .Slice (files , arrange )
152
151
153
152
/*
154
153
Order of files:
155
- /etc/nginx/conf.d/config-version.conf
156
154
/etc/nginx/conf.d/http.conf
157
155
/etc/nginx/conf.d/matches.json
158
156
/etc/nginx/includes/http_snippet1.conf
@@ -172,13 +170,8 @@ func TestGenerate(t *testing.T) {
172
170
*/
173
171
174
172
g .Expect (files [0 ].Type ).To (Equal (file .TypeRegular ))
175
- g .Expect (files [0 ].Path ).To (Equal ("/etc/nginx/conf.d/config-version.conf" ))
176
- configVersion := string (files [0 ].Content )
177
- g .Expect (configVersion ).To (ContainSubstring (fmt .Sprintf ("return 200 %d" , conf .Version )))
178
-
179
- g .Expect (files [1 ].Type ).To (Equal (file .TypeRegular ))
180
- g .Expect (files [1 ].Path ).To (Equal ("/etc/nginx/conf.d/http.conf" ))
181
- httpCfg := string (files [1 ].Content ) // converting to string so that on failure gomega prints strings not byte arrays
173
+ g .Expect (files [0 ].Path ).To (Equal ("/etc/nginx/conf.d/http.conf" ))
174
+ httpCfg := string (files [0 ].Content ) // converting to string so that on failure gomega prints strings not byte arrays
182
175
// Note: this only verifies that Generate() returns a byte array with upstream, server, and split_client blocks.
183
176
// It does not test the correctness of those blocks. That functionality is covered by other tests in this package.
184
177
g .Expect (httpCfg ).To (ContainSubstring ("listen 80" ))
@@ -195,66 +188,66 @@ func TestGenerate(t *testing.T) {
195
188
g .Expect (httpCfg ).To (ContainSubstring ("include /etc/nginx/includes/http_snippet1.conf;" ))
196
189
g .Expect (httpCfg ).To (ContainSubstring ("include /etc/nginx/includes/http_snippet2.conf;" ))
197
190
198
- g .Expect (files [2 ].Path ).To (Equal ("/etc/nginx/conf.d/matches.json" ))
191
+ g .Expect (files [1 ].Path ).To (Equal ("/etc/nginx/conf.d/matches.json" ))
199
192
200
- g .Expect (files [2 ].Type ).To (Equal (file .TypeRegular ))
193
+ g .Expect (files [1 ].Type ).To (Equal (file .TypeRegular ))
201
194
expString := "{}"
202
- g .Expect (string (files [2 ].Content )).To (Equal (expString ))
195
+ g .Expect (string (files [1 ].Content )).To (Equal (expString ))
203
196
204
197
// snippet include files
205
198
// content is not checked in this test.
206
- g .Expect (files [3 ].Path ).To (Equal ("/etc/nginx/includes/http_snippet1.conf" ))
207
- g .Expect (files [4 ].Path ).To (Equal ("/etc/nginx/includes/http_snippet2.conf" ))
208
- g .Expect (files [5 ].Path ).To (Equal ("/etc/nginx/includes/main_snippet1.conf" ))
209
- g .Expect (files [6 ].Path ).To (Equal ("/etc/nginx/includes/main_snippet2.conf" ))
199
+ g .Expect (files [2 ].Path ).To (Equal ("/etc/nginx/includes/http_snippet1.conf" ))
200
+ g .Expect (files [3 ].Path ).To (Equal ("/etc/nginx/includes/http_snippet2.conf" ))
201
+ g .Expect (files [4 ].Path ).To (Equal ("/etc/nginx/includes/main_snippet1.conf" ))
202
+ g .Expect (files [5 ].Path ).To (Equal ("/etc/nginx/includes/main_snippet2.conf" ))
210
203
211
- g .Expect (files [7 ].Path ).To (Equal ("/etc/nginx/main-includes/deployment_ctx.json" ))
212
- deploymentCtx := string (files [7 ].Content )
204
+ g .Expect (files [6 ].Path ).To (Equal ("/etc/nginx/main-includes/deployment_ctx.json" ))
205
+ deploymentCtx := string (files [6 ].Content )
213
206
g .Expect (deploymentCtx ).To (ContainSubstring ("\" integration\" :\" ngf\" " ))
214
207
g .Expect (deploymentCtx ).To (ContainSubstring ("\" cluster_id\" :\" test-uid\" " ))
215
208
g .Expect (deploymentCtx ).To (ContainSubstring ("\" installation_id\" :\" test-uid-replicaSet\" " ))
216
209
g .Expect (deploymentCtx ).To (ContainSubstring ("\" cluster_node_count\" :1" ))
217
210
218
- g .Expect (files [8 ].Path ).To (Equal ("/etc/nginx/main-includes/main.conf" ))
219
- mainConfStr := string (files [8 ].Content )
211
+ g .Expect (files [7 ].Path ).To (Equal ("/etc/nginx/main-includes/main.conf" ))
212
+ mainConfStr := string (files [7 ].Content )
220
213
g .Expect (mainConfStr ).To (ContainSubstring ("load_module modules/ngx_otel_module.so;" ))
221
214
g .Expect (mainConfStr ).To (ContainSubstring ("include /etc/nginx/includes/main_snippet1.conf;" ))
222
215
g .Expect (mainConfStr ).To (ContainSubstring ("include /etc/nginx/includes/main_snippet2.conf;" ))
223
216
224
- g .Expect (files [9 ].Path ).To (Equal ("/etc/nginx/main-includes/mgmt.conf" ))
225
- mgmtConf := string (files [9 ].Content )
217
+ g .Expect (files [8 ].Path ).To (Equal ("/etc/nginx/main-includes/mgmt.conf" ))
218
+ mgmtConf := string (files [8 ].Content )
226
219
g .Expect (mgmtConf ).To (ContainSubstring ("usage_report endpoint=test-endpoint" ))
227
220
g .Expect (mgmtConf ).To (ContainSubstring ("license_token /etc/nginx/secrets/license.jwt" ))
228
221
g .Expect (mgmtConf ).To (ContainSubstring ("deployment_context /etc/nginx/main-includes/deployment_ctx.json" ))
229
222
g .Expect (mgmtConf ).To (ContainSubstring ("ssl_trusted_certificate /etc/nginx/secrets/mgmt-ca.crt" ))
230
223
g .Expect (mgmtConf ).To (ContainSubstring ("ssl_certificate /etc/nginx/secrets/mgmt-tls.crt" ))
231
224
g .Expect (mgmtConf ).To (ContainSubstring ("ssl_certificate_key /etc/nginx/secrets/mgmt-tls.key" ))
232
225
233
- g .Expect (files [10 ].Path ).To (Equal ("/etc/nginx/secrets/license.jwt" ))
234
- g .Expect (string (files [10 ].Content )).To (Equal ("license" ))
226
+ g .Expect (files [9 ].Path ).To (Equal ("/etc/nginx/secrets/license.jwt" ))
227
+ g .Expect (string (files [9 ].Content )).To (Equal ("license" ))
235
228
236
- g .Expect (files [11 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-ca.crt" ))
237
- g .Expect (string (files [11 ].Content )).To (Equal ("ca" ))
229
+ g .Expect (files [10 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-ca.crt" ))
230
+ g .Expect (string (files [10 ].Content )).To (Equal ("ca" ))
238
231
239
- g .Expect (files [12 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-tls.crt" ))
240
- g .Expect (string (files [12 ].Content )).To (Equal ("cert" ))
232
+ g .Expect (files [11 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-tls.crt" ))
233
+ g .Expect (string (files [11 ].Content )).To (Equal ("cert" ))
241
234
242
- g .Expect (files [13 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-tls.key" ))
243
- g .Expect (string (files [13 ].Content )).To (Equal ("key" ))
235
+ g .Expect (files [12 ].Path ).To (Equal ("/etc/nginx/secrets/mgmt-tls.key" ))
236
+ g .Expect (string (files [12 ].Content )).To (Equal ("key" ))
244
237
245
- g .Expect (files [14 ].Path ).To (Equal ("/etc/nginx/secrets/test-certbundle.crt" ))
246
- certBundle := string (files [14 ].Content )
238
+ g .Expect (files [13 ].Path ).To (Equal ("/etc/nginx/secrets/test-certbundle.crt" ))
239
+ certBundle := string (files [13 ].Content )
247
240
g .Expect (certBundle ).To (Equal ("test-cert" ))
248
241
249
- g .Expect (files [15 ]).To (Equal (file.File {
242
+ g .Expect (files [14 ]).To (Equal (file.File {
250
243
Type : file .TypeSecret ,
251
244
Path : "/etc/nginx/secrets/test-keypair.pem" ,
252
245
Content : []byte ("test-cert\n test-key" ),
253
246
}))
254
247
255
- g .Expect (files [16 ].Path ).To (Equal ("/etc/nginx/stream-conf.d/stream.conf" ))
256
- g .Expect (files [16 ].Type ).To (Equal (file .TypeRegular ))
257
- streamCfg := string (files [16 ].Content )
248
+ g .Expect (files [15 ].Path ).To (Equal ("/etc/nginx/stream-conf.d/stream.conf" ))
249
+ g .Expect (files [15 ].Type ).To (Equal (file .TypeRegular ))
250
+ streamCfg := string (files [15 ].Content )
258
251
g .Expect (streamCfg ).To (ContainSubstring ("listen unix:/var/run/nginx/app.example.com-443.sock" ))
259
252
g .Expect (streamCfg ).To (ContainSubstring ("listen 443" ))
260
253
g .Expect (streamCfg ).To (ContainSubstring ("app.example.com unix:/var/run/nginx/app.example.com-443.sock" ))
0 commit comments