mirror of
https://github.com/gofiber/storage.git
synced 2025-10-08 01:50:32 +08:00
chore: return a pointer to the generic suite
This commit is contained in:
@@ -145,7 +145,7 @@ func TestMySQLStorageTCK(t *testing.T) {
|
|||||||
s, err := tck.New[*Storage, *sql.DB](context.Background(), t, &MySQLStorageTCK{}, tck.PerTest())
|
s, err := tck.New[*Storage, *sql.DB](context.Background(), t, &MySQLStorageTCK{}, tck.PerTest())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
suite.Run(t, &s)
|
suite.Run(t, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Benchmark_MYSQL_Set(b *testing.B) {
|
func Benchmark_MYSQL_Set(b *testing.B) {
|
||||||
|
@@ -76,9 +76,9 @@ type TCKSuite[T storage.Storage, D any, C testcontainers.Container] interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new [StorageTestSuite] with the given [TCKSuite].
|
// New creates a new [StorageTestSuite] with the given [TCKSuite].
|
||||||
func New[T storage.Storage, D any, C testcontainers.Container](ctx context.Context, t *testing.T, tckSuite TCKSuite[T, D, C], opts ...suiteOption) (StorageTestSuite[T, D, C], error) {
|
func New[T storage.Storage, D any, C testcontainers.Container](ctx context.Context, t *testing.T, tckSuite TCKSuite[T, D, C], opts ...suiteOption) (*StorageTestSuite[T, D, C], error) {
|
||||||
if tckSuite == nil {
|
if tckSuite == nil {
|
||||||
return StorageTestSuite[T, D, C]{}, fmt.Errorf("test suite is nil")
|
return nil, fmt.Errorf("test suite is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
s := StorageTestSuite[T, D, C]{
|
s := StorageTestSuite[T, D, C]{
|
||||||
@@ -90,13 +90,13 @@ func New[T storage.Storage, D any, C testcontainers.Container](ctx context.Conte
|
|||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
if err := opt.apply(&s); err != nil {
|
if err := opt.apply(&s); err != nil {
|
||||||
return StorageTestSuite[T, D, C]{}, fmt.Errorf("apply option: %w", err)
|
return nil, fmt.Errorf("apply option: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s.SetT(t)
|
s.SetT(t)
|
||||||
|
|
||||||
return s, nil
|
return &s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StorageTestSuite is the test suite for the storage.
|
// StorageTestSuite is the test suite for the storage.
|
||||||
|
Reference in New Issue
Block a user