Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithConfigFile ¶
func WithConfigFile(configFile string) testcontainers.CustomizeRequestOption
WithConfigFile sets the config file to be used for the redis container, and sets the command to run the redis server using the passed config file
func WithLogLevel ¶
func WithLogLevel(level LogLevel) testcontainers.CustomizeRequestOption
WithLogLevel sets the log level for the redis server process See https://redis.io/docs/reference/modules/modules-api-ref/#redismodule_log for more information.
func WithSnapshotting ¶
WithSnapshotting sets the snapshotting configuration for the redis server process. You can configure Redis to have it save the dataset every N seconds if there are at least M changes in the dataset. This method allows Redis to benefit from copy-on-write semantics. See https://redis.io/docs/management/persistence/#snapshotting for more information.
Types ¶
type LogLevel ¶
type LogLevel string
const ( // LogLevelDebug is the debug log level LogLevelDebug LogLevel = "debug" // LogLevelVerbose is the verbose log level LogLevelVerbose LogLevel = "verbose" // LogLevelNotice is the notice log level LogLevelNotice LogLevel = "notice" // LogLevelWarning is the warning log level LogLevelWarning LogLevel = "warning" )
type RedisContainer ¶
type RedisContainer struct {
testcontainers.Container
}
func Run ¶ added in v0.32.0
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*RedisContainer, error)
Run creates an instance of the Redis container type
Example ¶
// runRedisContainer { ctx := context.Background() redisContainer, err := redis.Run(ctx, "redis:7", redis.WithSnapshotting(10, 1), redis.WithLogLevel(redis.LogLevelVerbose), redis.WithConfigFile(filepath.Join("testdata", "redis7.conf")), ) defer func() { if err := testcontainers.TerminateContainer(redisContainer); err != nil { log.Printf("failed to terminate container: %s", err) } }() if err != nil { log.Printf("failed to start container: %s", err) return } // } state, err := redisContainer.State(ctx) if err != nil { log.Printf("failed to get container state: %s", err) return } fmt.Println(state.Running)
Output: true
func RunContainer
deprecated
func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomizer) (*RedisContainer, error)
Deprecated: use Run instead RunContainer creates an instance of the Redis container type
func (*RedisContainer) ConnectionString ¶
func (c *RedisContainer) ConnectionString(ctx context.Context) (string, error)