Files
kopia/internal/blobtesting/storage.go
ashmrtn bb27e3147e test(repository): More precise check for retention in tests (#3220)
* Store and return retention info in test storage

Add a new interface and function that allows getting retention
information during testing. This allows for more exact comparisons about
retention duration and mode in tests.

* Fixup how blobtesting retention extension works

Use the clock instead of the object's mod time so that extensions are
from the "current time." This aligns with how the S3 blob storage
functions.

* Update retention tests to use more precise checks

Where possible, use the information returned by GetRetention in tests
that deal with retention information. This allows for more precise
comparions of retention duration and mode instead of indirectly testing
duration by advancing the clock and attempting to modify blobs.
2023-08-15 16:53:27 +00:00

18 lines
516 B
Go

package blobtesting
import (
"context"
"time"
"github.com/kopia/kopia/repo/blob"
)
// RetentionStorage allows for better testing of retention and object
// locking-related code by allowing callers to get the retention parameters of
// the blob and attempt "modifying" the blob with TouchBlob.
type RetentionStorage interface {
blob.Storage
TouchBlob(ctx context.Context, id blob.ID, threshold time.Duration) (time.Time, error)
GetRetention(context.Context, blob.ID) (blob.RetentionMode, time.Time, error)
}