tc

package module
v0.0.0-...-f32bd8a Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 3 Imported by: 0

README

Testcontainer factories

Test container factories are sweet.DepFactory implementations that bootstrap starting containers for testing.

The containers

  • clean themselves up after tests
  • start up ready to serve traffic
    • client tests should never have to call time.Sleep before testing
    • client tests should never fail due to a container dependency not being ready
  • start tests as soon as they're ready to serve traffic
    • client tests should not be waiting because a factory is calling time.Sleep

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContainer

func NewContainer(t *testing.T, ctx context.Context, c Container) testcontainers.Container

NewContainer sets up and runs a docker container for the given image.

The container is cleaned up when the test ends.

func NewFactory

func NewFactory(ctx context.Context, c Container) func(t *testing.T) testcontainers.Container

NewFactory generates a sweet compatible DepFactory that spins up Redis test containers of the given image.

Types

type Container

type Container interface {
	Request() testcontainers.ContainerRequest
	Close(ctx context.Context, container testcontainers.Container) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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