@@ -519,54 +519,65 @@ func TestListenerNamesHaveOverlap(t *testing.T) {
519
519
tests := []struct {
520
520
hostname1 * v1.Hostname
521
521
hostname2 * v1.Hostname
522
+ msg string
522
523
expectResult bool
523
524
}{
524
525
{
525
526
hostname1 : (* v1 .Hostname )(helpers .GetPointer ("*.example.com" )),
526
527
hostname2 : (* v1 .Hostname )(helpers .GetPointer ("*.example.com" )),
527
528
expectResult : true ,
529
+ msg : "same hostnames with wildcard" ,
528
530
},
529
531
{
530
532
hostname1 : nil ,
531
533
hostname2 : nil ,
532
534
expectResult : true ,
535
+ msg : "two nil hostnames" ,
533
536
},
534
537
{
535
538
hostname1 : (* v1 .Hostname )(helpers .GetPointer ("cafe.example.com" )),
536
539
hostname2 : (* v1 .Hostname )(helpers .GetPointer ("app.example.com" )),
537
540
expectResult : false ,
541
+ msg : "two different hostnames no wildcard" ,
538
542
},
539
543
{
540
544
hostname1 : (* v1 .Hostname )(helpers .GetPointer ("cafe.example.com" )),
541
545
hostname2 : nil ,
542
546
expectResult : true ,
547
+ msg : "hostname1 is nil" ,
543
548
},
544
549
{
545
550
hostname1 : nil ,
546
551
hostname2 : (* v1 .Hostname )(helpers .GetPointer ("cafe.example.com" )),
547
552
expectResult : true ,
553
+ msg : "hostname2 is nil" ,
548
554
},
549
555
{
550
556
hostname1 : (* v1 .Hostname )(helpers .GetPointer ("*.example.com" )),
551
557
hostname2 : (* v1 .Hostname )(helpers .GetPointer ("*.example.org" )),
552
558
expectResult : false ,
559
+ msg : "wildcard hostnames that do not overlap" ,
553
560
},
554
561
{
555
562
hostname1 : (* v1 .Hostname )(helpers .GetPointer ("*.example.com" )),
556
563
hostname2 : (* v1 .Hostname )(helpers .GetPointer ("cafe.example.com" )),
557
564
expectResult : true ,
565
+ msg : "one wildcard hostname and one hostname that overlap" ,
558
566
},
559
567
}
560
568
561
569
for _ , test := range tests {
562
- g := NewWithT (t )
563
- g .Expect (haveOverlap (test .hostname1 , test .hostname2 )).To (Equal (test .expectResult ))
570
+ t .Run (test .msg , func (t * testing.T ) {
571
+ g := NewWithT (t )
572
+ g .Expect (haveOverlap (test .hostname1 , test .hostname2 )).To (Equal (test .expectResult ))
573
+ })
564
574
}
565
575
}
566
576
567
577
func TestValidateTLSFieldOnTLSListener (t * testing.T ) {
568
578
tests := []struct {
569
579
listener v1.Listener
580
+ msg string
570
581
expectedCond []conditions.Condition
571
582
expectValid bool
572
583
}{
@@ -576,39 +587,37 @@ func TestValidateTLSFieldOnTLSListener(t *testing.T) {
576
587
"TLS: Required value: tls must be defined for TLS listener" ,
577
588
),
578
589
expectValid : false ,
579
- },
580
- {
581
- listener : v1.Listener {},
582
- expectedCond : staticConds .NewListenerUnsupportedValue (
583
- "TLS: Required value: tls must be defined for TLS listener" ,
584
- ),
585
- expectValid : false ,
590
+ msg : "TLS listener without tls field" ,
586
591
},
587
592
{
588
593
listener : v1.Listener {TLS : nil },
589
594
expectedCond : staticConds .NewListenerUnsupportedValue (
590
595
"TLS: Required value: tls must be defined for TLS listener" ,
591
596
),
592
597
expectValid : false ,
598
+ msg : "TLS listener with TLS field nil" ,
593
599
},
594
600
{
595
601
listener : v1.Listener {TLS : & v1.GatewayTLSConfig {Mode : helpers .GetPointer (v1 .TLSModeTerminate )}},
596
602
expectedCond : staticConds .NewListenerUnsupportedValue (
597
603
"TLS.Mode: Required value: Mode must be passthrough for TLS listener" ,
598
604
),
599
605
expectValid : false ,
606
+ msg : "TLS listener with TLS mode terminate" ,
600
607
},
601
608
{
602
609
listener : v1.Listener {TLS : & v1.GatewayTLSConfig {Mode : helpers .GetPointer (v1 .TLSModePassthrough )}},
603
610
expectValid : true ,
611
+ msg : "TLS listener with TLS mode passthrough" ,
604
612
},
605
613
}
606
614
for _ , test := range tests {
607
- g := NewWithT ( t )
608
-
609
- cond , valid := validateTLSFieldOnTLSListener (test .listener )
615
+ t . Run ( test . msg , func ( t * testing. T ) {
616
+ g := NewWithT ( t )
617
+ cond , valid := validateTLSFieldOnTLSListener (test .listener )
610
618
611
- g .Expect (cond ).To (BeEquivalentTo (test .expectedCond ))
612
- g .Expect (valid ).To (BeEquivalentTo (test .expectValid ))
619
+ g .Expect (cond ).To (BeEquivalentTo (test .expectedCond ))
620
+ g .Expect (valid ).To (BeEquivalentTo (test .expectValid ))
621
+ })
613
622
}
614
623
}
0 commit comments