dockertestx

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package dockertestx is wrapper of ory/dockertest.

dockertestx provides ready specific persistent and containers management to reuse.

Index

Examples

Constants

View Source
const (
	S3AWSAccessKeyID     = "AKIAIOSFODNN7DUMMY"                     // #nosec
	S3AWSSecretAccessKey = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYDUMMYKEY" // #nosec
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerFactory added in v0.4.0

type ContainerFactory interface {
	// contains filtered or unexported methods
}

ContainerFactory represents how to create docker container

type ContainerOption added in v0.4.0

type ContainerOption struct {
	// Name of docker container
	// it must be present when use same factories
	Name string

	// Tag of docker image
	Tag string
}

type DynamoDBFactory added in v0.4.0

type DynamoDBFactory struct{}

type Pool added in v0.4.0

type Pool struct {
	*dockertest.Pool
	// contains filtered or unexported fields
}

Pool represents a connection to the docker API and is used to create and remove docker images.

func New added in v0.4.0

func New(opt PoolOption) (*Pool, error)

New Pool instance

Example
package main

import (
	"database/sql"
	"log"

	"github.com/tier4/x-go/dockertestx"
)

func main() {
	p, err := dockertestx.New(dockertestx.PoolOption{})
	if err != nil {
		// handle error
		return
	}
	defer func(p *dockertestx.Pool) {
		err := p.Purge()
		if err != nil {
			log.Fatalln(err)
		}
	}(p)

	dsn, err := p.NewResource(new(dockertestx.PostgresFactory), dockertestx.ContainerOption{
		Tag: "13-alpine",
	})
	if err != nil {
		// handle error
		return
	}

	db, err := sql.Open("postgres", dsn)
	if err != nil {
		// handle error
		return
	}
	defer db.Close()
}
Output:

func (*Pool) ForcePurge added in v0.4.0

func (p *Pool) ForcePurge() error

ForcePurge regardless KeepContainer option

func (*Pool) NewResource added in v0.4.0

func (p *Pool) NewResource(factory ContainerFactory, opt ContainerOption) (string, error)

func (*Pool) Purge added in v0.4.0

func (p *Pool) Purge() error

Purge if KeepContainer option is false

func (*Pool) Save added in v0.4.0

func (p *Pool) Save() error

Save states to reuse containers next time

type PoolOption added in v0.4.0

type PoolOption struct {
	// KeepContainer or not
	// if true, write container state to StateStore when calling Pool.Save()
	KeepContainer bool

	// StateStore of docker container state for using container
	// this must be present when KeepContainer is true
	StateStore *os.File
}

type PostgresFactory added in v0.4.0

type PostgresFactory struct{}

type PrismFactory added in v0.12.0

type PrismFactory struct {
	// SpecURI is a file path or URL of the OpenAPI Specification.
	SpecURI string

	// HealthCheckPath is the path accessed to verify that the stub server has started.
	// The response status code is ignored.
	// The default is to use the base path.
	HealthCheckPath string
}

type S3Factory added in v0.5.0

type S3Factory struct{}

Jump to

Keyboard shortcuts

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