testutil

package
v0.0.0-...-55fe43a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package testutil provides shared test infrastructure for integration tests.

Index

Constants

View Source
const StorageBackendName = "minio"

StorageBackendName is the default backend name used in tests.

View Source
const TestBucket = "test-bucket"

TestBucket is the default bucket name used in tests.

Variables

This section is empty.

Functions

func WaitFor

func WaitFor(t *testing.T, timeout time.Duration, msg string, condition func() bool)

WaitFor polls condition every 100ms until it returns true or timeout expires.

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.

func (*ConcatCompressor) Compress

func (c *ConcatCompressor) Compress(_ context.Context, inputDir, outputDir string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL