MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestFileReadEmptyTreeOldSide

Function TestFileReadEmptyTreeOldSide

internal/tool/code_access_test.go:230–247  ·  view source on GitHub ↗
(test *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestFileReadEmptyTreeOldSide(test *testing.T) {
231 access, err := NewComparisonCodeAccess(FileReader{Mode: ModeCommit, Ref: "HEAD"}, FileReader{Mode: ModeEmpty})
232 if err != nil {
233 test.Fatal(err)
234 }
235 provider := FileReadProvider{Access: access}
236 for path, reason := range map[string]string{
237 ".": `"." is a directory; file_read does not support directories.`,
238 "./": `"./" is a directory; file_read does not support directories.`,
239 "missing": `file "missing" does not exist in the empty tree.`,
240 } {
241 got, err := provider.Execute(test.Context(), map[string]any{"file_path": path, "side": "old"})
242 var pathErr *FileReadPathError
243 if got != "" || !errors.As(err, &pathErr) || err.Error() != "SIDE: old\nSOURCE: empty-tree\n"+reason {
244 test.Errorf("old side %q: got %q, %v", path, got, err)
245 }
246 }
247}
248
249func TestWorkspaceCodeAccess(test *testing.T) {
250 current, previous := comparisonReaders(test)

Callers

nothing calls this directly

Calls 3

ExecuteMethod · 0.95
NewComparisonCodeAccessFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected