mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
Fixing k8s.io/kubernetes/cmd/kubeadm/app/util/staticpod unit tests on Windows
Signed-off-by: Mark Rossetti <marosset@microsoft.com>
This commit is contained in:
parent
2ca9e2d28f
commit
c186de0080
@ -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