MCPcopy Index your code
hub / github.com/coder/coder / TestListFilesListDrives

Function TestListFilesListDrives

agent/agentfiles/ls_internal_test.go:199–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

197}
198
199func 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}

Callers

nothing calls this directly

Calls 3

listFilesFunction · 0.85
SkipMethod · 0.80
ContainsMethod · 0.45

Tested by

no test coverage detected