mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
add test for String
modify
This commit is contained in:
parent
a4a22a2562
commit
2422e99df3
@ -50,3 +50,26 @@ func TestAPIEndpointFromString(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestString(t *testing.T) {
|
||||
var tests = []struct {
|
||||
name string
|
||||
apiEndpoint APIEndpoint
|
||||
expected string
|
||||
}{
|
||||
{name: "ipv4 and port", apiEndpoint: APIEndpoint{AdvertiseAddress: "1.2.3.4", BindPort: 1234}, expected: "1.2.3.4:1234"},
|
||||
{name: "ipv6 and port", apiEndpoint: APIEndpoint{AdvertiseAddress: "::1", BindPort: 1234}, expected: "[::1]:1234"},
|
||||
}
|
||||
for _, rt := range tests {
|
||||
t.Run(rt.name, func(t *testing.T) {
|
||||
apiEndpointString := rt.apiEndpoint.String()
|
||||
if apiEndpointString != rt.expected {
|
||||
t.Errorf(
|
||||
"failed String:\n\texpected: %s\n\t actual: %s",
|
||||
rt.expected,
|
||||
apiEndpointString,
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user