diff options
| author | 2025-11-16 00:00:00 +0000 | |
|---|---|---|
| committer | 2025-11-16 00:00:00 +0000 | |
| commit | bad0f9715556a470d0de2a22c7040181e3a033ba (patch) | |
| tree | 21463072ce5bc85682a887ce0cae26d833941af3 /testutil_sha256_test.go | |
| parent | EntryRecursive should return ErrNotFound instead of nil, nil (diff) | |
| signature | ||
Use actual git for tests and enhance Head
Diffstat (limited to 'testutil_sha256_test.go')
| -rw-r--r-- | testutil_sha256_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/testutil_sha256_test.go b/testutil_sha256_test.go new file mode 100644 index 00000000..70ed6f19 --- /dev/null +++ b/testutil_sha256_test.go @@ -0,0 +1,29 @@ +//go:build !sha1 + +package furgit + +import ( + "os" + "os/exec" + "testing" +) + +func setupTestRepo(t *testing.T) (string, func()) { + t.Helper() + tempDir, err := os.MkdirTemp("", "furgit-test-*") + if err != nil { + t.Fatalf("failed to create temp dir: %v", err) + } + cleanup := func() { + _ = os.RemoveAll(tempDir) + } + + cmd := exec.Command("git", "init", "--object-format=sha256", "--bare", tempDir) + cmd.Env = append(os.Environ(), "GIT_CONFIG_GLOBAL=/dev/null", "GIT_CONFIG_SYSTEM=/dev/null") + if output, err := cmd.CombinedOutput(); err != nil { + cleanup() + t.Fatalf("failed to init git repo: %v\n%s", err, output) + } + + return tempDir, cleanup +} |
