(t *testing.T)
| 1025 | } |
| 1026 | |
| 1027 | func TestValidateDevice(t *testing.T) { |
| 1028 | skip.If(t, runtime.GOOS != "linux") // Windows and macOS validate server-side |
| 1029 | valid := []string{ |
| 1030 | "/home", |
| 1031 | "/home:/home", |
| 1032 | "/home:/something/else", |
| 1033 | "/with space", |
| 1034 | "/home:/with space", |
| 1035 | "relative:/absolute-path", |
| 1036 | "hostPath:/containerPath:r", |
| 1037 | "/hostPath:/containerPath:rw", |
| 1038 | "/hostPath:/containerPath:mrw", |
| 1039 | } |
| 1040 | invalid := map[string]string{ |
| 1041 | "": "bad format for path: ", |
| 1042 | "./": "./ is not an absolute path", |
| 1043 | "../": "../ is not an absolute path", |
| 1044 | "/:../": "../ is not an absolute path", |
| 1045 | "/:path": "path is not an absolute path", |
| 1046 | ":": "bad format for path: :", |
| 1047 | "/tmp:": " is not an absolute path", |
| 1048 | ":test": "bad format for path: :test", |
| 1049 | ":/test": "bad format for path: :/test", |
| 1050 | "tmp:": " is not an absolute path", |
| 1051 | ":test:": "bad format for path: :test:", |
| 1052 | "::": "bad format for path: ::", |
| 1053 | ":::": "bad format for path: :::", |
| 1054 | "/tmp:::": "bad format for path: /tmp:::", |
| 1055 | ":/tmp::": "bad format for path: :/tmp::", |
| 1056 | "path:ro": "ro is not an absolute path", |
| 1057 | "path:rr": "rr is not an absolute path", |
| 1058 | "a:/b:ro": "bad mode specified: ro", |
| 1059 | "a:/b:rr": "bad mode specified: rr", |
| 1060 | } |
| 1061 | |
| 1062 | for _, path := range valid { |
| 1063 | if _, err := validateDevice(path, runtime.GOOS); err != nil { |
| 1064 | t.Fatalf("ValidateDevice(`%q`) should succeed: error %q", path, err) |
| 1065 | } |
| 1066 | } |
| 1067 | |
| 1068 | for path, expectedError := range invalid { |
| 1069 | if _, err := validateDevice(path, runtime.GOOS); err == nil { |
| 1070 | t.Fatalf("ValidateDevice(`%q`) should have failed validation", path) |
| 1071 | } else if err.Error() != expectedError { |
| 1072 | t.Fatalf("ValidateDevice(`%q`) error should contain %q, got %q", path, expectedError, err.Error()) |
| 1073 | } |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | func TestParseSystemPaths(t *testing.T) { |
| 1078 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…