diff options
Diffstat (limited to 'objectstore')
| -rw-r--r-- | objectstore/loose/read_test.go | 4 | ||||
| -rw-r--r-- | objectstore/loose/write_test.go | 52 | ||||
| -rw-r--r-- | objectstore/packed/helpers_test.go | 2 | ||||
| -rw-r--r-- | objectstore/packed/read_test.go | 2 |
4 files changed, 30 insertions, 30 deletions
diff --git a/objectstore/loose/read_test.go b/objectstore/loose/read_test.go index 8663ef1f..d125629a 100644 --- a/objectstore/loose/read_test.go +++ b/objectstore/loose/read_test.go @@ -15,7 +15,7 @@ import ( func TestLooseStoreReadAgainstGit(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}) blobID := testRepo.HashObject(t, "blob", []byte("blob body\n")) _, treeID, commitID := testRepo.MakeCommit(t, "subject\n\nbody") tagID := testRepo.TagAnnotated(t, "v1", commitID, "tag message") @@ -94,7 +94,7 @@ func TestLooseStoreReadAgainstGit(t *testing.T) { func TestLooseStoreErrors(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}) store := openLooseStore(t, testRepo.Dir(), algo) notFoundID, err := objectid.ParseHex(algo, strings.Repeat("0", algo.HexLen())) diff --git a/objectstore/loose/write_test.go b/objectstore/loose/write_test.go index 0dcb3a5f..b9a318d2 100644 --- a/objectstore/loose/write_test.go +++ b/objectstore/loose/write_test.go @@ -13,7 +13,7 @@ import ( func TestLooseStoreWriteWriterContentAgainstGit(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}) store := openLooseStore(t, testRepo.Dir(), algo) content := []byte("written-by-content-writer\n") @@ -41,35 +41,35 @@ func TestLooseStoreWriteWriterContentAgainstGit(t *testing.T) { t.Fatalf("WriteWriterContent id = %s, want %s", writtenID, expectedID) } - gotBody := testRepo.CatFile(t, "blob", writtenID) - if !bytes.Equal(gotBody, content) { - t.Fatalf("git cat-file body mismatch") - } + gotBody := testRepo.CatFile(t, "blob", writtenID) + if !bytes.Equal(gotBody, content) { + t.Fatalf("git cat-file body mismatch") + } - // Writing the same object again should succeed and return the same ID. - writer, finalize, err = store.WriteWriterContent(objecttype.TypeBlob, int64(len(content))) - if err != nil { - t.Fatalf("WriteWriterContent second: %v", err) - } - if _, err := io.Copy(writer, bytes.NewReader(content)); err != nil { - t.Fatalf("WriteWriterContent second write: %v", err) - } - if err := writer.Close(); err != nil { - t.Fatalf("WriteWriterContent second close: %v", err) - } - writtenID2, err := finalize() - if err != nil { - t.Fatalf("WriteWriterContent second finalize: %v", err) - } - if writtenID2 != expectedID { - t.Fatalf("WriteWriterContent second id = %s, want %s", writtenID2, expectedID) - } - }) + // Writing the same object again should succeed and return the same ID. + writer, finalize, err = store.WriteWriterContent(objecttype.TypeBlob, int64(len(content))) + if err != nil { + t.Fatalf("WriteWriterContent second: %v", err) + } + if _, err := io.Copy(writer, bytes.NewReader(content)); err != nil { + t.Fatalf("WriteWriterContent second write: %v", err) + } + if err := writer.Close(); err != nil { + t.Fatalf("WriteWriterContent second close: %v", err) + } + writtenID2, err := finalize() + if err != nil { + t.Fatalf("WriteWriterContent second finalize: %v", err) + } + if writtenID2 != expectedID { + t.Fatalf("WriteWriterContent second id = %s, want %s", writtenID2, expectedID) + } + }) } func TestLooseStoreWriteWriterFullAgainstGit(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}) store := openLooseStore(t, testRepo.Dir(), algo) body := []byte("full-writer-body\n") @@ -109,7 +109,7 @@ func TestLooseStoreWriteWriterFullAgainstGit(t *testing.T) { func TestLooseStoreWriterValidationErrors(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}) store := openLooseStore(t, testRepo.Dir(), algo) t.Run("content overflow", func(t *testing.T) { diff --git a/objectstore/packed/helpers_test.go b/objectstore/packed/helpers_test.go index 5af44f66..f8cbd439 100644 --- a/objectstore/packed/helpers_test.go +++ b/objectstore/packed/helpers_test.go @@ -68,7 +68,7 @@ func expectedRawObject(t *testing.T, testRepo *testgit.TestRepo, id objectid.Obj func createPackedFixtureRepo(t *testing.T, algo objectid.Algorithm) (*testgit.TestRepo, []objectid.ObjectID) { t.Helper() - testRepo := testgit.NewBareRepo(t, algo) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo, Bare: true}) blobID, treeID, commitID := testRepo.MakeCommit(t, "packed store base commit") testRepo.Run(t, "update-ref", "refs/heads/main", commitID.String()) tagID := testRepo.TagAnnotated(t, "v1.0.0", commitID, "packed-store-tag") diff --git a/objectstore/packed/read_test.go b/objectstore/packed/read_test.go index 9244d573..0eb78366 100644 --- a/objectstore/packed/read_test.go +++ b/objectstore/packed/read_test.go @@ -136,7 +136,7 @@ func TestPackedStoreNewValidation(t *testing.T) { } func TestPackedStoreInvalidAlgorithm(t *testing.T) { - testRepo := testgit.NewBareRepo(t, objectid.AlgorithmSHA1) + testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: objectid.AlgorithmSHA1, Bare: true}) root, err := os.OpenRoot(testRepo.Dir()) if err != nil { t.Fatalf("OpenRoot(%q): %v", testRepo.Dir(), err) |
