@@ -433,53 +433,60 @@ func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_AddsSortedContentFrontE
433
433
s .Equal (expectedData , actualData )
434
434
}
435
435
436
- //func (s HaProxyTestSuite) Test_CreateConfigFromTemplates_PutsServicesWithRootPathToTheEnd() {
437
- // var actualData string
438
- // tmpl := s.TemplateContent
439
- // expectedData := fmt.Sprintf(
440
- // `%s
441
- // acl url_acl11111 path_beg /path
442
- // use_backend my-second-service-be1111 if url_acl11111
443
- // acl url_acl21111 path_beg /path
444
- // use_backend my-first-service-be1111 if url_acl21111
445
- // acl url_the-last-service1111 path_beg /path
446
- // use_backend the-last-service-be1111 if url_the-last-service1111%s`,
447
- // tmpl,
448
- // s.ServicesContent,
449
- // )
450
- // writeFile = func(filename string, data []byte, perm os.FileMode) error {
451
- // actualData = string(data)
452
- // return nil
453
- // }
454
- // p := NewHaProxy(s.TemplatesPath, s.ConfigsPath)
455
- // // Will be listed second because of AclName
456
- // data.Services["my-first-service"] = Service{
457
- // ServiceName: "my-first-service",
458
- // AclName: "acl2",
459
- // ServiceDest: []ServiceDest{
460
- // {Port: "1111", ServicePath: []string{"/path"}},
461
- // },
462
- // }
463
- // // Will be listed last because of ServiceName (there is no AclName)
464
- // data.Services["the-last-service"] = Service{
465
- // ServiceName: "the-last-service",
466
- // ServiceDest: []ServiceDest{
467
- // {Port: "1111", ServicePath: []string{"/path"}},
468
- // },
469
- // }
470
- // // Will be listed first because of AclName
471
- // data.Services["my-second-service"] = Service{
472
- // ServiceName: "my-second-service",
473
- // AclName: "acl1",
474
- // ServiceDest: []ServiceDest{
475
- // {Port: "1111", ServicePath: []string{"/path"}},
476
- // },
477
- // }
478
- //
479
- // p.CreateConfigFromTemplates()
480
- //
481
- // s.Equal(expectedData, actualData)
482
- //}
436
+ func (s HaProxyTestSuite ) Test_CreateConfigFromTemplates_PutsServicesWithRootPathToTheEnd () {
437
+ var actualData string
438
+ tmpl := s .TemplateContent
439
+ expectedData := fmt .Sprintf (
440
+ `%s
441
+ acl url_01-first-service1111 path_beg /path
442
+ use_backend 01-first-service-be1111 if url_01-first-service1111
443
+ acl url_03-third-service1111 path_beg /path
444
+ use_backend 03-third-service-be1111 if url_03-third-service1111
445
+ acl url_02-another-root-service1111 path_beg /
446
+ use_backend 02-another-root-service-be1111 if url_02-another-root-service1111
447
+ acl url_02-root-service1111 path_beg /
448
+ use_backend 02-root-service-be1111 if url_02-root-service1111%s` ,
449
+ tmpl ,
450
+ s .ServicesContent ,
451
+ )
452
+ writeFile = func (filename string , data []byte , perm os.FileMode ) error {
453
+ actualData = string (data )
454
+ return nil
455
+ }
456
+ p := NewHaProxy (s .TemplatesPath , s .ConfigsPath )
457
+ // Will be listed first
458
+ data .Services ["01-first-service" ] = Service {
459
+ ServiceName : "01-first-service" ,
460
+ ServiceDest : []ServiceDest {
461
+ {Port : "1111" , ServicePath : []string {"/path" }},
462
+ },
463
+ }
464
+ // Will be listed last bacause of the root path and service name
465
+ data .Services ["02-root-service" ] = Service {
466
+ ServiceName : "02-root-service" ,
467
+ ServiceDest : []ServiceDest {
468
+ {Port : "1111" , ServicePath : []string {"/" }},
469
+ },
470
+ }
471
+ // Will be listed third because of the root path and service name
472
+ data .Services ["02-another-root-service" ] = Service {
473
+ ServiceName : "02-another-root-service" ,
474
+ ServiceDest : []ServiceDest {
475
+ {Port : "1111" , ServicePath : []string {"/" }},
476
+ },
477
+ }
478
+ // Will be listed second
479
+ data .Services ["03-third-service" ] = Service {
480
+ ServiceName : "03-third-service" ,
481
+ ServiceDest : []ServiceDest {
482
+ {Port : "1111" , ServicePath : []string {"/path" }},
483
+ },
484
+ }
485
+
486
+ p .CreateConfigFromTemplates ()
487
+
488
+ s .Equal (expectedData , actualData )
489
+ }
483
490
484
491
func (s HaProxyTestSuite ) Test_CreateConfigFromTemplates_AddsContentFrontEndTcp () {
485
492
var actualData string
0 commit comments