MCPcopy Index your code
hub / github.com/coder/coder / initTestRepo

Function initTestRepo

agent/agentgit/agentgit_test.go:44–62  ·  view source on GitHub ↗

initTestRepo creates a temporary git repo with an initial commit and returns the repo root path.

(t *testing.T)

Source from the content-addressed store, hash-verified

42// initTestRepo creates a temporary git repo with an initial commit
43// and returns the repo root path.
44func 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
64func TestSubscribeBulkPathsAndDedupes(t *testing.T) {
65 t.Parallel()

Calls 4

TempDirResolvedFunction · 0.92
gitCmdFunction · 0.85
HelperMethod · 0.65
WriteFileMethod · 0.65

Tested by

no test coverage detected