initTestRepo creates a temporary git repo with an initial commit and returns the repo root path.
(t *testing.T)
| 42 | // initTestRepo creates a temporary git repo with an initial commit |
| 43 | // and returns the repo root path. |
| 44 | func initTestRepo(t *testing.T) string { |
| 45 | t.Helper() |
| 46 | // Resolve symlinks and short (8.3) names on Windows so test |
| 47 | // expectations match the canonical paths returned by git. |
| 48 | dir := testutil.TempDirResolved(t) |
| 49 | |
| 50 | gitCmd(t, dir, "init") |
| 51 | gitCmd(t, dir, "config", "user.name", "Test") |
| 52 | gitCmd(t, dir, "config", "user.email", "test@test.com") |
| 53 | |
| 54 | // Create a file and commit it so the repo has HEAD. |
| 55 | testFile := filepath.Join(dir, "README.md") |
| 56 | require.NoError(t, os.WriteFile(testFile, []byte("# Test\n"), 0o600)) |
| 57 | |
| 58 | gitCmd(t, dir, "add", "README.md") |
| 59 | gitCmd(t, dir, "commit", "-m", "initial commit") |
| 60 | |
| 61 | return dir |
| 62 | } |
| 63 | |
| 64 | func TestSubscribeBulkPathsAndDedupes(t *testing.T) { |
| 65 | t.Parallel() |
no test coverage detected