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

Function TestListFilesPermissionDenied

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

Source from the content-addressed store, hash-verified

57}
58
59func TestListFilesPermissionDenied(t *testing.T) {
60 t.Parallel()
61
62 fs := newTestFs(afero.NewMemMapFs())
63 home, err := os.UserHomeDir()
64 require.NoError(t, err)
65
66 tmpDir := t.TempDir()
67
68 reposDir := filepath.Join(tmpDir, "repos")
69 err = fs.MkdirAll(reposDir, 0o000)
70 require.NoError(t, err)
71
72 rel, err := filepath.Rel(home, reposDir)
73 require.NoError(t, err)
74
75 query := workspacesdk.LSRequest{
76 Path: pathToArray(rel),
77 Relativity: workspacesdk.LSRelativityHome,
78 }
79 _, err = listFiles(fs, "", query)
80 require.ErrorIs(t, err, os.ErrPermission)
81}
82
83func TestListFilesNotADirectory(t *testing.T) {
84 t.Parallel()

Callers

nothing calls this directly

Calls 5

pathToArrayFunction · 0.85
listFilesFunction · 0.85
MkdirAllMethod · 0.80
newTestFsFunction · 0.70
TempDirMethod · 0.65

Tested by

no test coverage detected