MCPcopy
hub / github.com/wavetermdev/waveterm / TestReadDirOnFile

Function TestReadDirOnFile

pkg/aiusechat/tools_readdir_test.go:92–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestReadDirOnFile(t *testing.T) {
93 // Create a temporary test file
94 tmpFile, err := os.CreateTemp("", "readdir_test_file")
95 if err != nil {
96 t.Fatalf("Failed to create temp file: %v", err)
97 }
98 defer os.Remove(tmpFile.Name())
99 tmpFile.Close()
100
101 // Test reading a file (should fail)
102 input := map[string]any{
103 "path": tmpFile.Name(),
104 }
105
106 _, err = readDirCallback(input, &uctypes.UIMessageDataToolUse{})
107 if err == nil {
108 t.Fatalf("Expected error when reading a file with read_dir, got nil")
109 }
110
111 expectedErrSubstr := "path is not a directory"
112 if err.Error()[:len(expectedErrSubstr)] != expectedErrSubstr {
113 t.Errorf("Expected error containing %q, got %q", expectedErrSubstr, err.Error())
114 }
115}
116
117func TestReadDirMaxEntries(t *testing.T) {
118 // Create a temporary test directory with many files

Callers

nothing calls this directly

Calls 4

readDirCallbackFunction · 0.85
CloseMethod · 0.65
NameMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected