Documentation
¶
Overview ¶
Package testutil provides shared test infrastructure for integration tests.
Index ¶
- Constants
- func WaitFor(t *testing.T, timeout time.Duration, msg string, condition func() bool)
- type ConcatCompressor
- type MariaDBContainer
- type MinIOContainer
- func (mc *MinIOContainer) ConnectionInfo() map[string]string
- func (mc *MinIOContainer) CreateBucket(t *testing.T, bucket string)
- func (mc *MinIOContainer) ObjectExists(t *testing.T, bucket, key string) bool
- func (mc *MinIOContainer) PutObject(t *testing.T, bucket, key string, data []byte)
- func (mc *MinIOContainer) Registry(name string) *storage.Registry
- func (mc *MinIOContainer) Teardown(t *testing.T)
Constants ¶
const StorageBackendName = "minio"
StorageBackendName is the default backend name used in tests.
const TestBucket = "test-bucket"
TestBucket is the default bucket name used in tests.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConcatCompressor ¶
type ConcatCompressor struct{}
ConcatCompressor is a test compressor that concatenates all files in the input directory into a single file in the output directory. It replaces clp-s in integration tests where a real CLP binary is not available.
type MariaDBContainer ¶
type MariaDBContainer struct {
Container testcontainers.Container
DB *sql.DB
DSN string
}
MariaDBContainer holds a running MariaDB container and a connected *sql.DB.
func SetupMariaDB ¶
func SetupMariaDB(t *testing.T) *MariaDBContainer
SetupMariaDB starts a MariaDB testcontainer and returns a connected *sql.DB. The caller should defer Teardown().
func (*MariaDBContainer) CreateTestTable ¶
func (mc *MariaDBContainer) CreateTestTable(t *testing.T, tableName string)
CreateTestTable provisions a metadata table by cloning _clp_template and inserting the required registry rows.
func (*MariaDBContainer) LoadSchema ¶
func (mc *MariaDBContainer) LoadSchema(t *testing.T)
LoadSchema reads schema.sql and executes all statements against the database.
func (*MariaDBContainer) Teardown ¶
func (mc *MariaDBContainer) Teardown(t *testing.T)
Teardown closes the database connection and terminates the container.
type MinIOContainer ¶
type MinIOContainer struct {
Container *minio.MinioContainer
Client *s3.Client
Backend storage.Backend
Endpoint string
}
MinIOContainer holds a running MinIO container, an S3 client, and a storage Backend.
func SetupMinIO ¶
func SetupMinIO(t *testing.T) *MinIOContainer
SetupMinIO starts a MinIO testcontainer and returns a connected client. The caller should defer Teardown().
func SetupMinIOWithBucket ¶
func SetupMinIOWithBucket(t *testing.T) *MinIOContainer
SetupMinIOWithBucket is a convenience that starts MinIO and creates a test bucket.
func (*MinIOContainer) ConnectionInfo ¶
func (mc *MinIOContainer) ConnectionInfo() map[string]string
ConnectionInfo returns the details needed to construct an S3Backend externally.
func (*MinIOContainer) CreateBucket ¶
func (mc *MinIOContainer) CreateBucket(t *testing.T, bucket string)
CreateBucket creates an S3 bucket in the MinIO container.
func (*MinIOContainer) ObjectExists ¶
func (mc *MinIOContainer) ObjectExists(t *testing.T, bucket, key string) bool
ObjectExists returns true if the object exists in MinIO.
func (*MinIOContainer) PutObject ¶
func (mc *MinIOContainer) PutObject(t *testing.T, bucket, key string, data []byte)
PutObject uploads a byte slice to MinIO.
func (*MinIOContainer) Registry ¶
func (mc *MinIOContainer) Registry(name string) *storage.Registry
Registry returns a storage.Registry with this MinIO backend registered under the given name.
func (*MinIOContainer) Teardown ¶
func (mc *MinIOContainer) Teardown(t *testing.T)
Teardown terminates the MinIO container.