@@ -21,6 +21,7 @@ import (
21
21
"os"
22
22
"path/filepath"
23
23
"reflect"
24
+ goruntime "runtime"
24
25
"sort"
25
26
"strconv"
26
27
"strings"
@@ -695,6 +696,17 @@ func TestReadStaticPodFromDisk(t *testing.T) {
695
696
}
696
697
}
697
698
699
+ // getFileNotFoundForOS returns the expected error message for a file not found error on the current OS
700
+ // - on Windows, the error message is "The system cannot find the file specified"
701
+ // - on other, the error message is "no such file or directory"
702
+ func getFileNotFoundForOS () string {
703
+ if goruntime .GOOS == "windows" {
704
+ return "The system cannot find the file specified"
705
+ } else {
706
+ return "no such file or directory"
707
+ }
708
+ }
709
+
698
710
func TestReadMultipleStaticPodsFromDisk (t * testing.T ) {
699
711
getTestPod := func (name string ) * v1.Pod {
700
712
return & v1.Pod {
@@ -738,9 +750,9 @@ func TestReadMultipleStaticPodsFromDisk(t *testing.T) {
738
750
setup : func (dir string ) {},
739
751
components : kubeadmconstants .ControlPlaneComponents ,
740
752
expectedErrorContains : []string {
741
- "kube-apiserver.yaml: no such file or directory" ,
742
- "kube-controller-manager.yaml: no such file or directory" ,
743
- "kube-scheduler.yaml: no such file or directory" ,
753
+ "kube-apiserver.yaml: " + getFileNotFoundForOS () ,
754
+ "kube-controller-manager.yaml: " + getFileNotFoundForOS () ,
755
+ "kube-scheduler.yaml: " + getFileNotFoundForOS () ,
744
756
},
745
757
},
746
758
}
0 commit comments