names unnamed testcases, adds name to t.Errorf msg

This commit is contained in:
RobertKielty 2020-08-11 13:57:16 +01:00
parent 04362870ad
commit 1eb1690a92

View File

@ -237,6 +237,7 @@ func TestRunInitNodeChecks(t *testing.T) {
expected: false,
},
{
name: "Test APIEndpoint exists if exists",
cfg: &kubeadmapi.InitConfiguration{
LocalAPIEndpoint: kubeadmapi.APIEndpoint{AdvertiseAddress: "2001:1234::1:15"},
},
@ -248,7 +249,8 @@ func TestRunInitNodeChecks(t *testing.T) {
actual := RunInitNodeChecks(exec.New(), rt.cfg, sets.NewString(), rt.isSecondaryControlPlane, rt.downloadCerts)
if (actual == nil) != rt.expected {
t.Errorf(
"failed RunInitNodeChecks:\n\texpected: %t\n\t actual: %t\n\t error: %v",
"failed RunInitNodeChecks:%v\n\texpected: %t\n\t actual: %t\n\t error: %v",
rt.name,
rt.expected,
(actual == nil),
actual,
@ -259,14 +261,17 @@ func TestRunInitNodeChecks(t *testing.T) {
func TestRunJoinNodeChecks(t *testing.T) {
var tests = []struct {
name string
cfg *kubeadmapi.JoinConfiguration
expected bool
}{
{
name: "Check empty JoinConfiguration",
cfg: &kubeadmapi.JoinConfiguration{},
expected: false,
},
{
name: "Check TLS Bootstrap APIServerEndpoint IPv4 addr",
cfg: &kubeadmapi.JoinConfiguration{
Discovery: kubeadmapi.Discovery{
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
@ -277,6 +282,7 @@ func TestRunJoinNodeChecks(t *testing.T) {
expected: false,
},
{
name: "Check TLS Bootstrap APIServerEndpoint IPv6 addr",
cfg: &kubeadmapi.JoinConfiguration{
Discovery: kubeadmapi.Discovery{
BootstrapToken: &kubeadmapi.BootstrapTokenDiscovery{
@ -292,7 +298,8 @@ func TestRunJoinNodeChecks(t *testing.T) {
actual := RunJoinNodeChecks(exec.New(), rt.cfg, sets.NewString())
if (actual == nil) != rt.expected {
t.Errorf(
"failed RunJoinNodeChecks:\n\texpected: %t\n\t actual: %t",
"failed RunJoinNodeChecks:%v\n\texpected: %t\n\t actual: %t",
rt.name,
rt.expected,
(actual != nil),
)