diff options
| author | 2026-02-21 12:31:51 +0800 | |
|---|---|---|
| committer | 2026-02-21 12:31:51 +0800 | |
| commit | 2852f9a20613b145fe36a8fde5bfd31ff7e82291 (patch) | |
| tree | 2df08e4a3f21e0db0f0eacf026bf392d3ba760f7 /objectstore/loose/write_test.go | |
| parent | testgit: Remove old new-repo helpers and use NewRepo with good RepoOptions (diff) | |
| signature | No signature | |
*: Use testgit.NewRepo
Diffstat (limited to 'objectstore/loose/write_test.go')
| -rw-r--r-- | objectstore/loose/write_test.go | 52 |
1 files changed, 26 insertions, 26 deletions
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) { |
