mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Add test for cmd/kubeadm/app/cmd/util/cmdutil.go
This commit is contained in:
parent
aea9f9887d
commit
20affda7f7
@ -17,6 +17,7 @@ limitations under the License.
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -70,3 +71,29 @@ 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) {
|
||||||
|
if GetKubeConfigPath(tt.file) != tt.expected {
|
||||||
|
t.Error("unexpected result")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user