mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #111502 from muyangren2/addtest_apiendpoint
add test for String
This commit is contained in:
commit
3a650c5c56
@ -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