mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Merge pull request #130289 from marosset/windows-unit-tests-cmd-kubeadm-app-util-static-pod-fixes
Fixing k8s.io/kubernetes/cmd/kubeadm/app/util/staticpod unit tests on Windows
This commit is contained in:
commit
19feb379b3
@ -21,6 +21,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
goruntime "runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -695,6 +696,17 @@ func TestReadStaticPodFromDisk(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getFileNotFoundForOS returns the expected error message for a file not found error on the current OS
|
||||||
|
// - on Windows, the error message is "The system cannot find the file specified"
|
||||||
|
// - on other, the error message is "no such file or directory"
|
||||||
|
func getFileNotFoundForOS() string {
|
||||||
|
if goruntime.GOOS == "windows" {
|
||||||
|
return "The system cannot find the file specified"
|
||||||
|
} else {
|
||||||
|
return "no such file or directory"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestReadMultipleStaticPodsFromDisk(t *testing.T) {
|
func TestReadMultipleStaticPodsFromDisk(t *testing.T) {
|
||||||
getTestPod := func(name string) *v1.Pod {
|
getTestPod := func(name string) *v1.Pod {
|
||||||
return &v1.Pod{
|
return &v1.Pod{
|
||||||
@ -738,9 +750,9 @@ func TestReadMultipleStaticPodsFromDisk(t *testing.T) {
|
|||||||
setup: func(dir string) {},
|
setup: func(dir string) {},
|
||||||
components: kubeadmconstants.ControlPlaneComponents,
|
components: kubeadmconstants.ControlPlaneComponents,
|
||||||
expectedErrorContains: []string{
|
expectedErrorContains: []string{
|
||||||
"kube-apiserver.yaml: no such file or directory",
|
"kube-apiserver.yaml: " + getFileNotFoundForOS(),
|
||||||
"kube-controller-manager.yaml: no such file or directory",
|
"kube-controller-manager.yaml: " + getFileNotFoundForOS(),
|
||||||
"kube-scheduler.yaml: no such file or directory",
|
"kube-scheduler.yaml: " + getFileNotFoundForOS(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user