MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / TestGetFileContentFromCommit_Success

Function TestGetFileContentFromCommit_Success

vcs/git/git_diff_test.go:461–476  ·  view source on GitHub ↗

Tests for GetFileContentFromCommit

(t *testing.T)

Source from the content-addressed store, hash-verified

459// Tests for GetFileContentFromCommit
460
461func TestGetFileContentFromCommit_Success(t *testing.T) {
462 tmpDir := t.TempDir()
463 setupGitRepo(t, tmpDir)
464
465 // Create and commit a file with specific content
466 content := "package main\n\nfunc main() {\n\tprintln(\"hello\")\n}\n"
467 createFile(t, tmpDir, "main.go", content)
468 gitAdd(t, tmpDir, "main.go")
469 commitID := gitCommitAndGetSHA(t, tmpDir, "Add main.go")
470
471 // Read the file content from commit
472 result, err := GetFileContentFromCommit(tmpDir, commitID, "main.go")
473
474 require.NoError(t, err)
475 assert.Equal(t, content, string(result))
476}
477
478func TestGetFileContentFromCommit_OlderCommit(t *testing.T) {
479 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 5

setupGitRepoFunction · 0.85
createFileFunction · 0.85
gitAddFunction · 0.85
gitCommitAndGetSHAFunction · 0.85
GetFileContentFromCommitFunction · 0.85

Tested by

no test coverage detected