Merge pull request #111656 from Octopusjust/k8s-pr7
Add test for cmd/kubeadm/app/cmd/util/cmdutil.go
This commit is contained in:
commit
94c70776ee
@ -18,6 +18,8 @@ package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
)
|
||||
|
||||
func TestValidateExactArgNumber(t *testing.T) {
|
||||
@ -70,3 +72,34 @@ func TestValidateExactArgNumber(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetKubeConfigPath(t *testing.T) {
|
||||
var tests = []struct {
|
||||
name string
|
||||
file string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
name: "provide an empty value",
|
||||
file: "",
|
||||
expected: clientcmd.NewDefaultClientConfigLoadingRules().GetDefaultFilename(),
|
||||
},
|
||||
{
|
||||
name: "provide a non-empty value",
|
||||
file: "kubelet.kubeconfig",
|
||||
expected: "kubelet.kubeconfig",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
actualResult := GetKubeConfigPath(tt.file)
|
||||
if actualResult != tt.expected {
|
||||
t.Errorf(
|
||||
"failed GetKubeConfigPath:\n\texpected: %s\n\t actual: %s",
|
||||
tt.expected,
|
||||
actualResult,
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user