containy

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 4 Imported by: 0

README

containy

containy is a Go library that simplifies container-based testing by providing a clean, declarative API on top of testcontainers-go. It helps you write more maintainable integration tests with less boilerplate.

Features

  • Declarative container configuration
  • Flexible wait strategies (logs, ports, health checks, HTTP)
  • Predefined templates for common services (Redis, PostgreSQL, Localstack)
  • Easy to extend and customize

Installation

go get github.com/akselarzuman/containy

Quick Start

See examples for a complete example.

Predefined Services

Redis
redis, err := c.CreateContainer(ctx, predefined.RedisConfig)
PostgreSQL
postgres, err := c.CreateContainer(ctx, predefined.PostgresConfig(
    "postgres", 
    "password",
    "testdb"))
Localstack
localstack, err := c.CreateContainer(ctx, predefined.LocalstackConfig(
    "dynamodb,s3",
    "us-east-1",
))

Custom Container Configuration

Create custom configurations for any container:

config := models.Config{
    Image:        "nginx:latest",
    Name:         "nginx-test",
    ExposedPorts: []string{"80:80/tcp"},
    WaitStrategy: models.WaitForHTTPResponse,
    WaitConfig: map[string]string{
        "path": "/",
        "port": "80/tcp",
    },
}

container, err := c.CreateContainer(ctx, config)

Custom postgres configuration:

config := models.Config{
    Image:        "postgres:13",
    Name:         "postgres-mock",
    ExposedPorts: []string{"5555:5432/tcp"},
    Env: map[string]string{
        "POSTGRES_USER":     "postgres",
        "POSTGRES_PASSWORD": "pgpwd",
        "POSTGRES_DB":       "containy",
    },
    Cmd:          []string{"postgres", "-c", "fsync=off"},
    WaitStrategy: models.WaitForPort,
    WaitConfig: map[string]string{
        "port": "5432/tcp",
    },
}

container, err := c.CreateContainer(ctx, config)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Containy

type Containy struct {
	// contains filtered or unexported fields
}

func New

func New() *Containy

func (*Containy) Cleanup

func (c *Containy) Cleanup(ctx context.Context) error

func (*Containy) CreateContainer

func (c *Containy) CreateContainer(ctx context.Context, config models.Config) (testcontainers.Container, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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