| 197 | } |
| 198 | |
| 199 | func TestListFilesListDrives(t *testing.T) { |
| 200 | t.Parallel() |
| 201 | |
| 202 | if runtime.GOOS != "windows" { |
| 203 | t.Skip("skipping test on non-Windows OS") |
| 204 | } |
| 205 | |
| 206 | fs := afero.NewOsFs() |
| 207 | query := workspacesdk.LSRequest{ |
| 208 | Path: []string{}, |
| 209 | Relativity: workspacesdk.LSRelativityRoot, |
| 210 | } |
| 211 | resp, err := listFiles(fs, "", query) |
| 212 | require.NoError(t, err) |
| 213 | require.Contains(t, resp.Contents, workspacesdk.LSFile{ |
| 214 | Name: "C:\\", |
| 215 | AbsolutePathString: "C:\\", |
| 216 | IsDir: true, |
| 217 | }) |
| 218 | |
| 219 | query = workspacesdk.LSRequest{ |
| 220 | Path: []string{"C:\\"}, |
| 221 | Relativity: workspacesdk.LSRelativityRoot, |
| 222 | } |
| 223 | resp, err = listFiles(fs, "", query) |
| 224 | require.NoError(t, err) |
| 225 | |
| 226 | query = workspacesdk.LSRequest{ |
| 227 | Path: resp.AbsolutePath, |
| 228 | Relativity: workspacesdk.LSRelativityRoot, |
| 229 | } |
| 230 | resp, err = listFiles(fs, "", query) |
| 231 | require.NoError(t, err) |
| 232 | // System directory should always exist |
| 233 | require.Contains(t, resp.Contents, workspacesdk.LSFile{ |
| 234 | Name: "Windows", |
| 235 | AbsolutePathString: "C:\\Windows", |
| 236 | IsDir: true, |
| 237 | }) |
| 238 | |
| 239 | query = workspacesdk.LSRequest{ |
| 240 | // Network drives are not supported. |
| 241 | Path: []string{"\\sshfs\\work"}, |
| 242 | Relativity: workspacesdk.LSRelativityRoot, |
| 243 | } |
| 244 | resp, err = listFiles(fs, "", query) |
| 245 | require.ErrorContains(t, err, "drive") |
| 246 | } |