Skip to content

Commit 209d517

Browse files
committed
comments
1 parent 672ae0f commit 209d517

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

internal/mode/static/state/graph/gateway_listener_test.go

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -519,54 +519,65 @@ func TestListenerNamesHaveOverlap(t *testing.T) {
519519
tests := []struct {
520520
hostname1 *v1.Hostname
521521
hostname2 *v1.Hostname
522+
msg string
522523
expectResult bool
523524
}{
524525
{
525526
hostname1: (*v1.Hostname)(helpers.GetPointer("*.example.com")),
526527
hostname2: (*v1.Hostname)(helpers.GetPointer("*.example.com")),
527528
expectResult: true,
529+
msg: "same hostnames with wildcard",
528530
},
529531
{
530532
hostname1: nil,
531533
hostname2: nil,
532534
expectResult: true,
535+
msg: "two nil hostnames",
533536
},
534537
{
535538
hostname1: (*v1.Hostname)(helpers.GetPointer("cafe.example.com")),
536539
hostname2: (*v1.Hostname)(helpers.GetPointer("app.example.com")),
537540
expectResult: false,
541+
msg: "two different hostnames no wildcard",
538542
},
539543
{
540544
hostname1: (*v1.Hostname)(helpers.GetPointer("cafe.example.com")),
541545
hostname2: nil,
542546
expectResult: true,
547+
msg: "hostname1 is nil",
543548
},
544549
{
545550
hostname1: nil,
546551
hostname2: (*v1.Hostname)(helpers.GetPointer("cafe.example.com")),
547552
expectResult: true,
553+
msg: "hostname2 is nil",
548554
},
549555
{
550556
hostname1: (*v1.Hostname)(helpers.GetPointer("*.example.com")),
551557
hostname2: (*v1.Hostname)(helpers.GetPointer("*.example.org")),
552558
expectResult: false,
559+
msg: "wildcard hostnames that do not overlap",
553560
},
554561
{
555562
hostname1: (*v1.Hostname)(helpers.GetPointer("*.example.com")),
556563
hostname2: (*v1.Hostname)(helpers.GetPointer("cafe.example.com")),
557564
expectResult: true,
565+
msg: "one wildcard hostname and one hostname that overlap",
558566
},
559567
}
560568

561569
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+
})
564574
}
565575
}
566576

567577
func TestValidateTLSFieldOnTLSListener(t *testing.T) {
568578
tests := []struct {
569579
listener v1.Listener
580+
msg string
570581
expectedCond []conditions.Condition
571582
expectValid bool
572583
}{
@@ -576,39 +587,37 @@ func TestValidateTLSFieldOnTLSListener(t *testing.T) {
576587
"TLS: Required value: tls must be defined for TLS listener",
577588
),
578589
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",
586591
},
587592
{
588593
listener: v1.Listener{TLS: nil},
589594
expectedCond: staticConds.NewListenerUnsupportedValue(
590595
"TLS: Required value: tls must be defined for TLS listener",
591596
),
592597
expectValid: false,
598+
msg: "TLS listener with TLS field nil",
593599
},
594600
{
595601
listener: v1.Listener{TLS: &v1.GatewayTLSConfig{Mode: helpers.GetPointer(v1.TLSModeTerminate)}},
596602
expectedCond: staticConds.NewListenerUnsupportedValue(
597603
"TLS.Mode: Required value: Mode must be passthrough for TLS listener",
598604
),
599605
expectValid: false,
606+
msg: "TLS listener with TLS mode terminate",
600607
},
601608
{
602609
listener: v1.Listener{TLS: &v1.GatewayTLSConfig{Mode: helpers.GetPointer(v1.TLSModePassthrough)}},
603610
expectValid: true,
611+
msg: "TLS listener with TLS mode passthrough",
604612
},
605613
}
606614
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)
610618

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+
})
613622
}
614623
}

internal/mode/static/state/graph/route_common_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,7 +2415,7 @@ func TestBindL4RouteToListeners(t *testing.T) {
24152415
}
24162416
}
24172417

2418-
func TestBuildL4RoutesForGateways(t *testing.T) {
2418+
func TestBuildL4RoutesForGateways_NoGateways(t *testing.T) {
24192419
g := NewWithT(t)
24202420

24212421
nsName := types.NamespacedName{Namespace: testNs, Name: "hi"}
@@ -2444,7 +2444,7 @@ func TestBuildL4RoutesForGateways(t *testing.T) {
24442444
)).To(BeNil())
24452445
}
24462446

2447-
func TestTryToAttachL4RouteToListeners(t *testing.T) {
2447+
func TestTryToAttachL4RouteToListeners_NoAttachableListeners(t *testing.T) {
24482448
g := NewWithT(t)
24492449

24502450
route := &L4Route{

0 commit comments

Comments
 (0)