(t *testing.T)
| 555 | } |
| 556 | |
| 557 | func TestObjectWritesWithRetention(t *testing.T) { |
| 558 | ctx, env := repotesting.NewEnvironment(t, repotesting.FormatNotImportant, repotesting.Options{ |
| 559 | NewRepositoryOptions: func(n *repo.NewRepositoryOptions) { |
| 560 | n.RetentionMode = blob.Governance |
| 561 | n.RetentionPeriod = time.Hour * 24 |
| 562 | }, |
| 563 | }) |
| 564 | |
| 565 | writer := env.RepositoryWriter.NewObjectWriter(ctx, object.WriterOptions{MetadataCompressor: "zstd-fastest"}) |
| 566 | _, err := writer.Write([]byte("the quick brown fox jumps over the lazy dog")) |
| 567 | require.NoError(t, err) |
| 568 | |
| 569 | _, err = writer.Result() |
| 570 | require.NoError(t, err) |
| 571 | |
| 572 | env.RepositoryWriter.ContentManager().Flush(ctx) |
| 573 | |
| 574 | var prefixesWithRetention []string |
| 575 | |
| 576 | versionedMap := testutil.EnsureType[cache.Storage](t, env.RootStorage()) |
| 577 | |
| 578 | for _, prefix := range content.PackBlobIDPrefixes { |
| 579 | prefixesWithRetention = append(prefixesWithRetention, string(prefix)) |
| 580 | } |
| 581 | |
| 582 | prefixesWithRetention = append(prefixesWithRetention, indexblob.V0IndexBlobPrefix, epoch.EpochManagerIndexUberPrefix, |
| 583 | format.KopiaRepositoryBlobID, format.KopiaBlobCfgBlobID) |
| 584 | |
| 585 | // make sure that we cannot set mtime on the kopia objects created due to the |
| 586 | // retention time constraint |
| 587 | require.NoError(t, versionedMap.ListBlobs(ctx, "", func(it blob.Metadata) error { |
| 588 | for _, prefix := range prefixesWithRetention { |
| 589 | if strings.HasPrefix(string(it.BlobID), prefix) { |
| 590 | _, err = versionedMap.TouchBlob(ctx, it.BlobID, 0) |
| 591 | require.Error(t, err, "expected error while touching blob %s", it.BlobID) |
| 592 | |
| 593 | return nil |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | _, err = versionedMap.TouchBlob(ctx, it.BlobID, 0) |
| 598 | require.NoError(t, err, "unexpected error while touching blob %s", it.BlobID) |
| 599 | |
| 600 | return nil |
| 601 | })) |
| 602 | } |
| 603 | |
| 604 | func TestWriteSessionFlushOnSuccess(t *testing.T) { |
| 605 | var beforeFlushCount, afterFlushCount atomic.Int32 |
nothing calls this directly
no test coverage detected