containers

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package containers implements various test containers for integration testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FTPTestContainer added in v0.3.0

type FTPTestContainer struct {
	Container testcontainers.Container
	Host      string
	Port      nat.Port // represents the *host* port struct
	User      string
	Password  string
}

FTPTestContainer is a wrapper around a testcontainers.Container that provides an FTP server for testing purposes. It allows file uploads, downloads, and directory operations.

func NewFTPTestContainer added in v0.3.0

func NewFTPTestContainer(ctx context.Context, t *testing.T) *FTPTestContainer

NewFTPTestContainer uses delfer/alpine-ftp-server, minimal env vars, fixed host port mapping syntax.

func NewFTPTestContainerE added in v0.5.0

func NewFTPTestContainerE(ctx context.Context) (*FTPTestContainer, error)

NewFTPTestContainerE uses delfer/alpine-ftp-server, minimal env vars, fixed host port mapping syntax. Returns error instead of using require.NoError, suitable for TestMain usage.

func (*FTPTestContainer) Close added in v0.3.0

func (fc *FTPTestContainer) Close(ctx context.Context) error

Close terminates the container

func (*FTPTestContainer) ConnectionString added in v0.3.0

func (fc *FTPTestContainer) ConnectionString() string

ConnectionString returns the FTP connection string for this container

func (*FTPTestContainer) DeleteFile added in v0.4.0

func (fc *FTPTestContainer) DeleteFile(ctx context.Context, remotePath string) error

DeleteFile deletes a file from the FTP server

func (*FTPTestContainer) GetFile added in v0.3.0

func (fc *FTPTestContainer) GetFile(ctx context.Context, remotePath, localPath string) error

GetFile downloads a file from the FTP server

func (*FTPTestContainer) GetIP added in v0.3.0

func (fc *FTPTestContainer) GetIP() string

GetIP returns the host IP address

func (*FTPTestContainer) GetPassword added in v0.3.0

func (fc *FTPTestContainer) GetPassword() string

GetPassword returns the FTP password

func (*FTPTestContainer) GetPort added in v0.3.0

func (fc *FTPTestContainer) GetPort() int

GetPort returns the mapped port

func (*FTPTestContainer) GetUser added in v0.3.0

func (fc *FTPTestContainer) GetUser() string

GetUser returns the FTP username

func (*FTPTestContainer) ListFiles added in v0.3.0

func (fc *FTPTestContainer) ListFiles(ctx context.Context, remotePath string) ([]ftp.Entry, error)

ListFiles lists files in a directory on the FTP server

func (*FTPTestContainer) SaveFile added in v0.3.0

func (fc *FTPTestContainer) SaveFile(ctx context.Context, localPath, remotePath string) error

SaveFile uploads a file to the FTP server

type LocalstackTestContainer

type LocalstackTestContainer struct {
	Container testcontainers.Container
	Endpoint  string
	// contains filtered or unexported fields
}

LocalstackTestContainer is a wrapper around a testcontainers.Container that provides an S3 endpoint

func NewLocalstackTestContainer

func NewLocalstackTestContainer(ctx context.Context, t *testing.T) *LocalstackTestContainer

NewLocalstackTestContainer creates a new Localstack test container and returns a LocalstackTestContainer instance

func NewLocalstackTestContainerE added in v0.5.0

func NewLocalstackTestContainerE(ctx context.Context) (*LocalstackTestContainer, error)

NewLocalstackTestContainerE creates a new Localstack test container and returns a LocalstackTestContainer instance. Returns error instead of using require.NoError, suitable for TestMain usage.

func (*LocalstackTestContainer) Close

Close terminates the container

func (*LocalstackTestContainer) DeleteFile added in v0.4.0

func (lc *LocalstackTestContainer) DeleteFile(ctx context.Context, bucketName, objectKey string) error

DeleteFile deletes an object from S3

func (*LocalstackTestContainer) GetFile added in v0.4.0

func (lc *LocalstackTestContainer) GetFile(ctx context.Context, bucketName, objectKey, localPath string) error

GetFile downloads a file from S3

func (*LocalstackTestContainer) ListFiles added in v0.4.0

func (lc *LocalstackTestContainer) ListFiles(ctx context.Context, bucketName, prefix string) ([]types.Object, error)

ListFiles lists objects in an S3 bucket, optionally with a prefix

func (*LocalstackTestContainer) MakeS3Connection

func (lc *LocalstackTestContainer) MakeS3Connection(ctx context.Context, t *testing.T) (client *s3.Client, bucketName string)

MakeS3Connection creates a new S3 connection using the test container endpoint and returns the connection and a bucket name

func (*LocalstackTestContainer) SaveFile added in v0.4.0

func (lc *LocalstackTestContainer) SaveFile(ctx context.Context, localPath, bucketName, objectKey string) error

SaveFile uploads a file to S3

type MongoTestContainer

type MongoTestContainer struct {
	Container testcontainers.Container
	URI       string
	Client    *mongo.Client
	// contains filtered or unexported fields
}

MongoTestContainer wraps testcontainers.Container and provides MongoDB client

func NewMongoTestContainer

func NewMongoTestContainer(ctx context.Context, t *testing.T, mongoVersion int) *MongoTestContainer

NewMongoTestContainer creates a new MongoDB test container

func NewMongoTestContainerE added in v0.5.0

func NewMongoTestContainerE(ctx context.Context, mongoVersion int) (*MongoTestContainer, error)

NewMongoTestContainerE creates a new MongoDB test container. Returns error instead of using require.NoError, suitable for TestMain usage.

func (*MongoTestContainer) Close

func (mc *MongoTestContainer) Close(ctx context.Context) error

Close disconnects client, terminates container and restores original environment

func (*MongoTestContainer) Collection

func (mc *MongoTestContainer) Collection(dbName string) *mongo.Collection

Collection returns a new collection with unique name for tests

type MySQLTestContainer

type MySQLTestContainer struct {
	Container testcontainers.Container
	Host      string
	Port      nat.Port
	User      string
	Password  string
	Database  string
}

MySQLTestContainer is a wrapper around a testcontainers.Container that provides a MySQL server

func NewMySQLTestContainer

func NewMySQLTestContainer(ctx context.Context, t *testing.T) *MySQLTestContainer

NewMySQLTestContainer creates a new MySQL test container with default settings

func NewMySQLTestContainerE added in v0.5.0

func NewMySQLTestContainerE(ctx context.Context) (*MySQLTestContainer, error)

NewMySQLTestContainerE creates a new MySQL test container with default settings. Returns error instead of using require.NoError, suitable for TestMain usage.

func NewMySQLTestContainerWithDB

func NewMySQLTestContainerWithDB(ctx context.Context, t *testing.T, dbName string) *MySQLTestContainer

NewMySQLTestContainerWithDB creates a new MySQL test container with a specific database name

func NewMySQLTestContainerWithDBE added in v0.5.0

func NewMySQLTestContainerWithDBE(ctx context.Context, dbName string) (*MySQLTestContainer, error)

NewMySQLTestContainerWithDBE creates a new MySQL test container with a specific database name. Returns error instead of using require.NoError, suitable for TestMain usage.

func (*MySQLTestContainer) Close

func (mc *MySQLTestContainer) Close(ctx context.Context) error

Close terminates the container

func (*MySQLTestContainer) ConnectionString

func (mc *MySQLTestContainer) ConnectionString() string

ConnectionString returns the MySQL connection string for this container

func (*MySQLTestContainer) DSN

func (mc *MySQLTestContainer) DSN() string

DSN returns the MySQL DSN for this container

type PostgresTestContainer

type PostgresTestContainer struct {
	Container testcontainers.Container
	Host      string
	Port      nat.Port
	User      string
	Password  string
	Database  string
}

PostgresTestContainer is a wrapper around a testcontainers.Container that provides a PostgreSQL server

func NewPostgresTestContainer

func NewPostgresTestContainer(ctx context.Context, t *testing.T) *PostgresTestContainer

NewPostgresTestContainer creates a new PostgreSQL test container with default settings

func NewPostgresTestContainerE added in v0.5.0

func NewPostgresTestContainerE(ctx context.Context) (*PostgresTestContainer, error)

NewPostgresTestContainerE creates a new PostgreSQL test container with default settings. Returns error instead of using require.NoError, suitable for TestMain usage.

func NewPostgresTestContainerWithDB

func NewPostgresTestContainerWithDB(ctx context.Context, t *testing.T, dbName string) *PostgresTestContainer

NewPostgresTestContainerWithDB creates a new PostgreSQL test container with a specific database name

func NewPostgresTestContainerWithDBE added in v0.5.0

func NewPostgresTestContainerWithDBE(ctx context.Context, dbName string) (*PostgresTestContainer, error)

NewPostgresTestContainerWithDBE creates a new PostgreSQL test container with a specific database name. Returns error instead of using require.NoError, suitable for TestMain usage.

func (*PostgresTestContainer) Close

func (pc *PostgresTestContainer) Close(ctx context.Context) error

Close terminates the container

func (*PostgresTestContainer) ConnectionString

func (pc *PostgresTestContainer) ConnectionString() string

ConnectionString returns the PostgreSQL connection string for this container

type SSHTestContainer

type SSHTestContainer struct {
	Container testcontainers.Container
	Host      string
	Port      nat.Port
	User      string
}

SSHTestContainer is a wrapper around a testcontainers.Container that provides an SSH server

func NewSSHTestContainer

func NewSSHTestContainer(ctx context.Context, t *testing.T) *SSHTestContainer

NewSSHTestContainer creates a new SSH test container and returns an SSHTestContainer instance

func NewSSHTestContainerE added in v0.5.0

func NewSSHTestContainerE(ctx context.Context) (*SSHTestContainer, error)

NewSSHTestContainerE creates a new SSH test container and returns an SSHTestContainer instance. Returns error instead of using require.NoError, suitable for TestMain usage.

func NewSSHTestContainerWithUser

func NewSSHTestContainerWithUser(ctx context.Context, t *testing.T, user string) *SSHTestContainer

NewSSHTestContainerWithUser creates a new SSH test container with a specific user

func NewSSHTestContainerWithUserE added in v0.5.0

func NewSSHTestContainerWithUserE(ctx context.Context, user string) (*SSHTestContainer, error)

NewSSHTestContainerWithUserE creates a new SSH test container with a specific user. Returns error instead of using require.NoError, suitable for TestMain usage.

func (*SSHTestContainer) Address

func (sc *SSHTestContainer) Address() string

Address returns the SSH server address in host:port format

func (*SSHTestContainer) Close

func (sc *SSHTestContainer) Close(ctx context.Context) error

Close terminates the container

func (*SSHTestContainer) DeleteFile added in v0.4.0

func (sc *SSHTestContainer) DeleteFile(ctx context.Context, remotePath string) error

DeleteFile deletes a file from the SSH server

func (*SSHTestContainer) GetFile added in v0.4.0

func (sc *SSHTestContainer) GetFile(ctx context.Context, remotePath, localPath string) error

GetFile downloads a file from the SSH server

func (*SSHTestContainer) ListFiles added in v0.4.0

func (sc *SSHTestContainer) ListFiles(ctx context.Context, remotePath string) ([]os.FileInfo, error)

ListFiles lists files in a directory on the SSH server

func (*SSHTestContainer) SaveFile added in v0.4.0

func (sc *SSHTestContainer) SaveFile(ctx context.Context, localPath, remotePath string) error

SaveFile uploads a file to the SSH server

Jump to

Keyboard shortcuts

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