containers

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 20 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 (*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) 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 (*LocalstackTestContainer) Close

Close terminates the container

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

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 (*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 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 (*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 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 (*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 NewSSHTestContainerWithUser

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

NewSSHTestContainerWithUser creates a new SSH test container with a specific user

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

Jump to

Keyboard shortcuts

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