From 2852f9a20613b145fe36a8fde5bfd31ff7e82291 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 21 Feb 2026 12:31:51 +0800 Subject: *: Use testgit.NewRepo --- refstore/loose/loose_test.go | 10 +++++----- refstore/packed/packed_test.go | 4 ++-- refstore/reftable/reftable_test.go | 6 +++++- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'refstore') diff --git a/refstore/loose/loose_test.go b/refstore/loose/loose_test.go index 63898721..935b4120 100644 --- a/refstore/loose/loose_test.go +++ b/refstore/loose/loose_test.go @@ -31,7 +31,7 @@ func openLooseStore(t *testing.T, repoPath string, algo objectid.Algorithm) *loo func TestLooseResolveAndResolveFully(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { - testRepo := testgit.NewBareRepo(t, algo) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) _, _, commitID := testRepo.MakeCommit(t, "loose refs commit") testRepo.UpdateRef(t, "refs/heads/main", commitID) testRepo.SymbolicRef(t, "HEAD", "refs/heads/main") @@ -78,7 +78,7 @@ func TestLooseResolveAndResolveFully(t *testing.T) { func TestLooseResolveFullyCycle(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { - testRepo := testgit.NewBareRepo(t, algo) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) testRepo.SymbolicRef(t, "refs/heads/a", "refs/heads/b") testRepo.SymbolicRef(t, "refs/heads/b", "refs/heads/a") @@ -91,7 +91,7 @@ func TestLooseResolveFullyCycle(t *testing.T) { func TestLooseListPattern(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { - testRepo := testgit.NewBareRepo(t, algo) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) _, _, commitID := testRepo.MakeCommit(t, "list refs commit") testRepo.UpdateRef(t, "refs/heads/main", commitID) testRepo.UpdateRef(t, "refs/heads/feature", commitID) @@ -132,7 +132,7 @@ func TestLooseListPattern(t *testing.T) { func TestLooseMalformedDetachedRef(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { - testRepo := testgit.NewBareRepo(t, algo) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) refPath := filepath.Join(testRepo.Dir(), "refs", "heads", "bad") if err := os.MkdirAll(filepath.Dir(refPath), 0o755); err != nil { t.Fatalf("MkdirAll: %v", err) @@ -150,7 +150,7 @@ func TestLooseMalformedDetachedRef(t *testing.T) { func TestLooseShorten(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { - testRepo := testgit.NewBareRepo(t, algo) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) _, _, commitID := testRepo.MakeCommit(t, "shorten refs commit") testRepo.UpdateRef(t, "refs/heads/main", commitID) testRepo.UpdateRef(t, "refs/tags/main", commitID) diff --git a/refstore/packed/packed_test.go b/refstore/packed/packed_test.go index 2c984cb9..c8f7f99c 100644 --- a/refstore/packed/packed_test.go +++ b/refstore/packed/packed_test.go @@ -32,7 +32,7 @@ func openPackedRefStoreFromRepo(t *testing.T, repoPath string, algo objectid.Alg func TestPackedResolveAndPeeled(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { - testRepo := testgit.NewBareRepo(t, algo) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) _, _, commitID := testRepo.MakeCommit(t, "packed refs commit") testRepo.UpdateRef(t, "refs/heads/main", commitID) tagID := testRepo.TagAnnotated(t, "v1.0.0", commitID, "annotated tag") @@ -86,7 +86,7 @@ func TestPackedResolveAndPeeled(t *testing.T) { func TestPackedListAndShorten(t *testing.T) { testgit.ForEachAlgorithm(t, func(t *testing.T, algo objectid.Algorithm) { - testRepo := testgit.NewBareRepo(t, algo) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) _, _, commitID := testRepo.MakeCommit(t, "packed refs list commit") testRepo.UpdateRef(t, "refs/heads/main", commitID) testRepo.UpdateRef(t, "refs/tags/main", commitID) diff --git a/refstore/reftable/reftable_test.go b/refstore/reftable/reftable_test.go index 28201af2..d6345f14 100644 --- a/refstore/reftable/reftable_test.go +++ b/refstore/reftable/reftable_test.go @@ -17,7 +17,11 @@ import ( // newBareReftableRepo creates a bare repository that uses reftable ref storage. func newBareReftableRepo(tb testing.TB, algo objectid.Algorithm) *testgit.TestRepo { tb.Helper() - return testgit.NewRepo(tb, algo, testgit.RepoOptions{Bare: true, RefFormat: "reftable"}) + return testgit.NewRepo(tb, testgit.RepoOptions{ + ObjectFormat: algo, + Bare: true, + RefFormat: "reftable", + }) } // openStore opens a reftable store against repoDir/reftable. -- cgit v1.3.1-10-gc9f91