-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
31 lines (31 loc) · 1.42 KB
/
doc.go
File metadata and controls
31 lines (31 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package testutil provides helpers for writing Go tests that exercise real
// Git repositories. Instead of mocking git command output, tests create actual
// repositories on disk, apply operations through fluent builders, and assert
// against real git state.
//
// The three main entry points are:
//
// - [CreateTestRepo] for quickly spinning up a single repository with files,
// branches, and remotes already configured.
// - [NewScenario] for building multi-repository topologies (local + bare
// remote, diverged clones, worktrees, conflict states).
// - [SnapshotRepo] / [RestoreSnapshot] for capturing expensive fixture state
// once and restoring it cheaply across subtests.
// - [CreateRewriteValidationFixture] plus blocked-string assertions for
// sanitize/rewrite validation across content, commit history, refs, and paths.
//
// All helpers integrate with Go's testing.T: repositories are created inside
// t.TempDir() and cleaned up automatically, and setup failures call t.Fatalf
// so errors surface close to the fixture code rather than deep in assertions.
//
// # Quickstart
//
// func TestMyFeature(t *testing.T) {
// repoPath := testutil.CreateTestRepo(t, testutil.RepoOptions{Name: "subject"})
// testutil.RunGitCmd(t, repoPath, "checkout", "-b", "feature")
// // exercise your code against repoPath
// if testutil.IsDirty(t, repoPath) {
// t.Fatal("expected clean repo")
// }
// }
package testutil