2026-03-18 19:55:09 +03:00
|
|
|
package gcs_test
|
2025-11-04 17:05:12 +01:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/fsouza/fake-gcs-server/fakestorage"
|
2026-05-13 18:48:55 +03:00
|
|
|
"github.com/imgproxy/imgproxy/v4/storage"
|
|
|
|
|
"github.com/imgproxy/imgproxy/v4/storage/testsuite"
|
|
|
|
|
"github.com/imgproxy/imgproxy/v4/testutil"
|
2025-11-04 17:05:12 +01:00
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ReaderTestSuite struct {
|
|
|
|
|
testsuite.ReaderSuite
|
|
|
|
|
|
|
|
|
|
gcsStorage testutil.LazyObj[*gcsStorageWrapper]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ReaderTestSuite) SetupSuite() {
|
|
|
|
|
s.ReaderSuite.SetupSuite()
|
|
|
|
|
|
|
|
|
|
s.TestContainer = "test-container"
|
|
|
|
|
s.TestObjectKey = "test-object.txt"
|
|
|
|
|
|
|
|
|
|
// Prepare GCS storage with initial objects
|
|
|
|
|
gcsInitialObjects := []fakestorage.Object{
|
|
|
|
|
{
|
|
|
|
|
ObjectAttrs: fakestorage.ObjectAttrs{
|
|
|
|
|
BucketName: s.TestContainer,
|
|
|
|
|
Name: s.TestObjectKey,
|
|
|
|
|
Updated: time.Now(),
|
|
|
|
|
},
|
|
|
|
|
Content: s.TestData,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize GCS storage
|
|
|
|
|
s.gcsStorage, _ = NewLazySuiteStorage(s.Lazy(), gcsInitialObjects)
|
|
|
|
|
|
|
|
|
|
s.Storage, _ = testutil.NewLazySuiteObj(s,
|
|
|
|
|
func() (storage.Reader, error) {
|
|
|
|
|
return s.gcsStorage().Storage, nil
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestReader(t *testing.T) {
|
|
|
|
|
suite.Run(t, new(ReaderTestSuite))
|
|
|
|
|
}
|