5
5
"testing"
6
6
7
7
"github.com/onsi/gomega"
8
- . "github.com/onsi/gomega"
9
8
10
9
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/extensions2/settings"
11
10
"github.com/kgateway-dev/kgateway/v2/internal/kgateway/wellknown"
@@ -26,9 +25,12 @@ func TestSettings(t *testing.T) {
26
25
expectedErrorStr string
27
26
}{
28
27
{
28
+ // TODO: this test case does not fail when a new field is added to Settings
29
+ // but not updated here. should it?
29
30
name : "defaults to empty or default values" ,
30
31
envVars : map [string ]string {},
31
32
expectedSettings : & settings.Settings {
33
+ DnsLookupFamily : "V4_PREFERRED" ,
32
34
EnableIstioIntegration : false ,
33
35
EnableAutoMtls : false ,
34
36
StsClusterName : "" ,
@@ -40,6 +42,7 @@ func TestSettings(t *testing.T) {
40
42
{
41
43
name : "all values set" ,
42
44
envVars : map [string ]string {
45
+ "KGW_DNS_LOOKUP_FAMILY" : "V4_ONLY" ,
43
46
"KGW_ENABLE_ISTIO_INTEGRATION" : "true" ,
44
47
"KGW_ENABLE_AUTO_MTLS" : "true" ,
45
48
"KGW_STS_CLUSTER_NAME" : "my-cluster" ,
@@ -48,6 +51,7 @@ func TestSettings(t *testing.T) {
48
51
"KGW_XDS_SERVICE_PORT" : "1234" ,
49
52
},
50
53
expectedSettings : & settings.Settings {
54
+ DnsLookupFamily : "V4_ONLY" ,
51
55
EnableIstioIntegration : true ,
52
56
EnableAutoMtls : true ,
53
57
StsClusterName : "my-cluster" ,
@@ -78,9 +82,10 @@ func TestSettings(t *testing.T) {
78
82
"KGW_ENABLE_AUTO_MTLS" : "true" ,
79
83
},
80
84
expectedSettings : & settings.Settings {
81
- EnableAutoMtls : true ,
82
- XdsServiceName : wellknown .DefaultXdsService ,
83
- XdsServicePort : wellknown .DefaultXdsPort ,
85
+ DnsLookupFamily : "V4_PREFERRED" ,
86
+ EnableAutoMtls : true ,
87
+ XdsServiceName : wellknown .DefaultXdsService ,
88
+ XdsServicePort : wellknown .DefaultXdsPort ,
84
89
},
85
90
},
86
91
}
@@ -92,21 +97,21 @@ func TestSettings(t *testing.T) {
92
97
t .Cleanup (func () {
93
98
for k := range tc .envVars {
94
99
err := os .Unsetenv (k )
95
- g .Expect (err ).NotTo (HaveOccurred ())
100
+ g .Expect (err ).NotTo (gomega . HaveOccurred ())
96
101
}
97
102
})
98
103
99
104
for k , v := range tc .envVars {
100
105
err := os .Setenv (k , v )
101
- g .Expect (err ).NotTo (HaveOccurred ())
106
+ g .Expect (err ).NotTo (gomega . HaveOccurred ())
102
107
}
103
108
s , err := settings .BuildSettings ()
104
109
if tc .expectedErrorStr != "" {
105
- g .Expect (err ).To (HaveOccurred ())
110
+ g .Expect (err ).To (gomega . HaveOccurred ())
106
111
g .Expect (err .Error ()).To (gomega .ContainSubstring (tc .expectedErrorStr ))
107
112
} else {
108
- g .Expect (err ).NotTo (HaveOccurred ())
109
- g .Expect (s ).To (Equal (tc .expectedSettings ))
113
+ g .Expect (err ).NotTo (gomega . HaveOccurred ())
114
+ g .Expect (s ).To (gomega . Equal (tc .expectedSettings ))
110
115
}
111
116
})
112
117
}
0 commit comments