diff --git a/testhelper/docker/resource/minio/minio.go b/testhelper/docker/resource/minio/minio.go index ff3ca2b6..ee10866e 100644 --- a/testhelper/docker/resource/minio/minio.go +++ b/testhelper/docker/resource/minio/minio.go @@ -12,6 +12,7 @@ import ( "path/filepath" "slices" "strings" + "time" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" @@ -32,9 +33,10 @@ type Resource struct { } type File struct { - Key string - Content string - Etag string + Key string + Content string + Etag string + LastModificationTime time.Time } func Setup(pool *dockertest.Pool, d resource.Cleaner, opts ...func(*Config)) (*Resource, error) { @@ -158,9 +160,10 @@ func (r *Resource) Contents(ctx context.Context, prefix string) ([]File, error) } contents = append(contents, File{ - Key: objInfo.Key, - Content: string(b), - Etag: objInfo.ETag, + Key: objInfo.Key, + Content: string(b), + Etag: objInfo.ETag, + LastModificationTime: objInfo.LastModified, }) } diff --git a/testhelper/docker/resource/minio/minio_test.go b/testhelper/docker/resource/minio/minio_test.go index 0ee8023e..4879b020 100644 --- a/testhelper/docker/resource/minio/minio_test.go +++ b/testhelper/docker/resource/minio/minio_test.go @@ -93,11 +93,22 @@ func TestMinioContents(t *testing.T) { files, err := minioResource.Contents(context.Background(), "test-bucket/") require.NoError(t, err) - require.Equal(t, []File{ - {Key: "test-bucket/empty", Content: "", Etag: etag3}, - {Key: "test-bucket/hello.txt", Content: "hello", Etag: etag1}, - {Key: "test-bucket/hello.txt.gz", Content: "hello compressed", Etag: etag2}, - }, files) + // LastModified is set after the file is uploaded, so we can't compare it + lo.ForEach(files, func(f File, _ int) { + switch f.Key { + case "test-bucket/hello.txt": + require.Equal(t, "hello", f.Content) + require.Equal(t, etag1, f.Etag) + case "test-bucket/hello.txt.gz": + require.Equal(t, "hello compressed", f.Content) + require.Equal(t, etag2, f.Etag) + case "test-bucket/empty": + require.Equal(t, "", f.Content) + require.Equal(t, etag3, f.Etag) + default: + t.Fatalf("unexpected file: %s", f.Key) + } + }) t.Run("canceled context", func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background())