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

Function TestListFilesNotADirectory

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

Source from the content-addressed store, hash-verified

81}
82
83func TestListFilesNotADirectory(t *testing.T) {
84 t.Parallel()
85
86 fs := afero.NewMemMapFs()
87 home, err := os.UserHomeDir()
88 require.NoError(t, err)
89
90 tmpDir := t.TempDir()
91 err = fs.MkdirAll(tmpDir, 0o755)
92 require.NoError(t, err)
93
94 filePath := filepath.Join(tmpDir, "file.txt")
95 err = afero.WriteFile(fs, filePath, []byte("content"), 0o600)
96 require.NoError(t, err)
97
98 rel, err := filepath.Rel(home, filePath)
99 require.NoError(t, err)
100
101 query := workspacesdk.LSRequest{
102 Path: pathToArray(rel),
103 Relativity: workspacesdk.LSRelativityHome,
104 }
105 _, err = listFiles(fs, "", query)
106 require.ErrorContains(t, err, "is not a directory")
107}
108
109func TestListFilesSuccess(t *testing.T) {
110 t.Parallel()

Callers

nothing calls this directly

Calls 5

pathToArrayFunction · 0.85
listFilesFunction · 0.85
MkdirAllMethod · 0.80
TempDirMethod · 0.65
WriteFileMethod · 0.65

Tested by

no test coverage detected