tstredis

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Docker repository.
	Repository = "redis"

	// Default tag.
	DefaultTag = "6.0.9-alpine"

	// Default container expire time.
	DefaultExpire uint = 120
)

Functions

This section is empty.

Types

type Options

type Options struct {
	// Tag of the repository. Default: DefaultTag.
	Tag string

	// If specified, data will be stored in this host directory.
	HostDataPath string

	// If specified, the port 6379/tcp will be mapped to it. Default: random port.
	HostPort uint16

	// Expire time (in seconds) of the container. Default: DefaultExpire.
	Expire uint

	// BaseRunOptions is the base options, will be overrided by above.
	BaseRunOptions dockertest.RunOptions
}

Options is options to run a redis test server.

type Resource

type Resource struct {
	// Redis server docker container.
	*dockertest.Resource

	// Actual options.
	Options
}

Resource represents a test redis server.

func Run

func Run(opts *Options) (*Resource, error)

Run is equivalent to RunFromPool(nil, opts).

func RunFromPool

func RunFromPool(pool *dockertest.Pool, opts *Options) (*Resource, error)

RunFromPool runs a test redis server. If pool is nil, tstsvc.DefaultPool() will be used. If opts is nil, the default options will be used.

func (*Resource) Addr

func (res *Resource) Addr() string

Addr returns the addr to connect to the test server.

func (*Resource) Client

func (res *Resource) Client() *redis.Client

Client returns a redis client to the test server.

Jump to

Keyboard shortcuts

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