@@ -978,7 +978,6 @@ func TestCreateServers(t *testing.T) {
978
978
ProxySetHeaders : httpBaseHeaders ,
979
979
Includes : []http.Include {
980
980
{
981
- Content : []byte ("match-addition" ),
982
981
Filename : includesFolder + "/match-addition.conf" ,
983
982
},
984
983
},
@@ -1001,11 +1000,9 @@ func TestCreateServers(t *testing.T) {
1001
1000
Includes : []http.Include {
1002
1001
{
1003
1002
Filename : includesFolder + "/server-addition-1.conf" ,
1004
- Content : []byte ("server-addition-1" ),
1005
1003
},
1006
1004
{
1007
1005
Filename : includesFolder + "/server-addition-2.conf" ,
1008
- Content : []byte ("server-addition-2" ),
1009
1006
},
1010
1007
},
1011
1008
},
@@ -1025,11 +1022,9 @@ func TestCreateServers(t *testing.T) {
1025
1022
Includes : []http.Include {
1026
1023
{
1027
1024
Filename : includesFolder + "/server-addition-1.conf" ,
1028
- Content : []byte ("server-addition-1" ),
1029
1025
},
1030
1026
{
1031
1027
Filename : includesFolder + "/server-addition-3.conf" ,
1032
- Content : []byte ("server-addition-3" ),
1033
1028
},
1034
1029
},
1035
1030
},
@@ -2355,15 +2350,12 @@ func TestCreateIncludes(t *testing.T) {
2355
2350
includes : []http.Include {
2356
2351
{
2357
2352
Filename : includesFolder + "/one.conf" ,
2358
- Content : []byte ("one" ),
2359
2353
},
2360
2354
{
2361
2355
Filename : includesFolder + "/two.conf" ,
2362
- Content : []byte ("two" ),
2363
2356
},
2364
2357
{
2365
2358
Filename : includesFolder + "/three.conf" ,
2366
- Content : []byte ("three" ),
2367
2359
},
2368
2360
},
2369
2361
},
@@ -2379,91 +2371,115 @@ func TestCreateIncludes(t *testing.T) {
2379
2371
}
2380
2372
}
2381
2373
2382
- func TestCreateIncludeFileResults (t * testing.T ) {
2383
- servers := []http.Server {
2384
- {
2385
- Locations : []http.Location {
2386
- {
2387
- Includes : []http.Include {
2388
- {
2389
- Filename : "include-1.conf" ,
2390
- Content : []byte ("include-1" ),
2391
- },
2392
- {
2393
- Filename : "include-2.conf" ,
2394
- Content : []byte ("include-2" ),
2395
- },
2396
- {
2397
- Filename : "include-3.conf" ,
2398
- Content : []byte ("include-3" ),
2374
+ func TestCreateAdditionFileResults (t * testing.T ) {
2375
+ conf := dataplane.Configuration {
2376
+ HTTPServers : []dataplane.VirtualServer {
2377
+ {
2378
+ Additions : []* dataplane.Addition {
2379
+ {
2380
+ Identifier : "include-1" ,
2381
+ Bytes : []byte ("include-1" ),
2382
+ },
2383
+ {
2384
+ Identifier : "include-2" ,
2385
+ Bytes : []byte ("include-2" ),
2386
+ },
2387
+ },
2388
+ PathRules : []dataplane.PathRule {
2389
+ {
2390
+ MatchRules : []dataplane.MatchRule {
2391
+ {
2392
+ Additions : []* dataplane.Addition {
2393
+ {
2394
+ Identifier : "include-3" ,
2395
+ Bytes : []byte ("include-3" ),
2396
+ },
2397
+ {
2398
+ Identifier : "include-4" ,
2399
+ Bytes : []byte ("include-4" ),
2400
+ },
2401
+ },
2402
+ },
2399
2403
},
2400
2404
},
2401
2405
},
2402
2406
},
2403
- Includes : []http.Include {
2404
- {
2405
- Filename : "include-1.conf" ,
2406
- Content : []byte ("include-1" ), // duplicate
2407
- },
2408
- {
2409
- Filename : "include-4.conf" ,
2410
- Content : []byte ("include-4" ),
2407
+ {
2408
+ Additions : []* dataplane.Addition {
2409
+ {
2410
+ Identifier : "include-1" , // dupe
2411
+ Bytes : []byte ("include-1" ),
2412
+ },
2413
+ {
2414
+ Identifier : "include-2" , // dupe
2415
+ Bytes : []byte ("include-2" ),
2416
+ },
2411
2417
},
2412
2418
},
2413
2419
},
2414
- {
2415
- Locations : []http.Location {
2416
- {
2417
- Includes : []http.Include {
2418
- {
2419
- Filename : "include-2.conf" ,
2420
- Content : []byte ("include-2" ), // duplicate
2421
- },
2422
- {
2423
- Filename : "include-5.conf" ,
2424
- Content : []byte ("include-5" ),
2425
- },
2420
+ SSLServers : []dataplane.VirtualServer {
2421
+ {
2422
+ Additions : []* dataplane.Addition {
2423
+ {
2424
+ Identifier : "include-1" , // dupe
2425
+ Bytes : []byte ("include-1" ),
2426
+ },
2427
+ {
2428
+ Identifier : "include-2" , // dupe
2429
+ Bytes : []byte ("include-2" ),
2426
2430
},
2427
2431
},
2428
- },
2429
- Includes : []http.Include {
2430
- {
2431
- Filename : "include-4.conf" ,
2432
- Content : []byte ("include-4" ), // duplicate
2433
- },
2434
- {
2435
- Filename : "include-6.conf" ,
2436
- Content : []byte ("include-6" ),
2432
+ PathRules : []dataplane.PathRule {
2433
+ {
2434
+ MatchRules : []dataplane.MatchRule {
2435
+ {
2436
+ Additions : []* dataplane.Addition {
2437
+ {
2438
+ Identifier : "include-3" ,
2439
+ Bytes : []byte ("include-3" ), // dupe
2440
+ },
2441
+ {
2442
+ Identifier : "include-5" ,
2443
+ Bytes : []byte ("include-5" ), // dupe
2444
+ },
2445
+ {
2446
+ Identifier : "include-6" ,
2447
+ Bytes : []byte ("include-6" ),
2448
+ },
2449
+ },
2450
+ },
2451
+ },
2452
+ },
2437
2453
},
2438
2454
},
2439
2455
},
2440
2456
}
2441
2457
2442
- results := createIncludeFileResults ( servers )
2458
+ results := createAdditionFileResults ( conf )
2443
2459
2444
2460
expResults := []executeResult {
2445
2461
{
2446
- dest : "include-1.conf" ,
2462
+ dest : includesFolder + "/" + "include-1.conf" ,
2447
2463
data : []byte ("include-1" ),
2448
2464
},
2449
2465
{
2450
- dest : "include-2.conf" ,
2466
+ dest : includesFolder + "/" + "include-2.conf" ,
2451
2467
data : []byte ("include-2" ),
2452
2468
},
2453
2469
{
2454
- dest : "include-3.conf" ,
2470
+ dest : includesFolder + "/" + "include-3.conf" ,
2455
2471
data : []byte ("include-3" ),
2456
2472
},
2457
2473
{
2458
- dest : "include-4.conf" ,
2474
+ dest : includesFolder + "/" + "include-4.conf" ,
2459
2475
data : []byte ("include-4" ),
2460
2476
},
2461
2477
{
2462
- dest : "include-5.conf" ,
2478
+ dest : includesFolder + "/" + "include-5.conf" ,
2463
2479
data : []byte ("include-5" ),
2464
2480
},
2465
2481
{
2466
- dest : "include-6.conf" ,
2482
+ dest : includesFolder + "/" + "include-6.conf" ,
2467
2483
data : []byte ("include-6" ),
2468
2484
},
2469
2485
}
@@ -2472,3 +2488,31 @@ func TestCreateIncludeFileResults(t *testing.T) {
2472
2488
2473
2489
g .Expect (results ).To (ConsistOf (expResults ))
2474
2490
}
2491
+
2492
+ func TestAdditionFilename (t * testing.T ) {
2493
+ tests := []struct {
2494
+ name string
2495
+ addition * dataplane.Addition
2496
+ expName string
2497
+ }{
2498
+ {
2499
+ name : "nil addition" ,
2500
+ addition : nil ,
2501
+ expName : "" ,
2502
+ },
2503
+ {
2504
+ name : "normal addition" ,
2505
+ addition : & dataplane.Addition {Identifier : "my-addition" },
2506
+ expName : includesFolder + "/" + "my-addition.conf" ,
2507
+ },
2508
+ }
2509
+
2510
+ for _ , test := range tests {
2511
+ t .Run (test .name , func (t * testing.T ) {
2512
+ g := NewWithT (t )
2513
+
2514
+ name := createAdditionFileName (test .addition )
2515
+ g .Expect (name ).To (Equal (test .expName ))
2516
+ })
2517
+ }
2518
+ }
0 commit comments