Tests for GetFileContentFromCommit
(t *testing.T)
| 459 | // Tests for GetFileContentFromCommit |
| 460 | |
| 461 | func 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 | |
| 478 | func TestGetFileContentFromCommit_OlderCommit(t *testing.T) { |
| 479 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected