View Source Testcontainers.RedisContainer (testcontainers v1.11.6)

Provides functionality for creating and managing Redis container configurations.

Summary

Functions

Generates the connection URL for accessing the Redis service running within the container.

Retrieves the default Docker image for the Redis container.

Creates a new RedisContainer struct with default configurations.

Returns the port on the host machine where the Redis container is listening.

Set the regular expression to check the image validity.

Overrides the default image used for the Redis container.

Overrides the default port used for the Redis container.

Set the reuse flag to reuse the container if it is already running.

Overrides the default wait timeout used for the Redis container.

Functions

Link to this function

connection_url(container)

View Source

Generates the connection URL for accessing the Redis service running within the container.

This URL is based on the standard localhost IP and the mapped port for the container.

Parameters

  • container: The active Redis container instance in the form of a %Container{} struct.

Examples

iex> RedisContainer.connection_url(container)
"http://localhost:32768" # This value will be different depending on the mapped port.

Retrieves the default Docker image for the Redis container.

Creates a new RedisContainer struct with default configurations.

Returns the port on the host machine where the Redis container is listening.

Link to this function

with_check_image(config, check_image)

View Source

Set the regular expression to check the image validity.

Link to this function

with_image(config, image)

View Source

Overrides the default image used for the Redis container.

Examples

iex> config = RedisContainer.new()
iex> new_config = RedisContainer.with_image(config, "redis:xyz")
iex> new_config.image
"redis:xyz"

Overrides the default port used for the Redis container.

Note: this will not change what port the docker container is listening to internally.

Examples

iex> config = RedisContainer.new()
iex> new_config = RedisContainer.with_port(config, 1111)
iex> new_config.port
1111
Link to this function

with_reuse(config, reuse)

View Source

Set the reuse flag to reuse the container if it is already running.

Link to this function

with_wait_timeout(config, wait_timeout)

View Source

Overrides the default wait timeout used for the Redis container.

Note: this timeout will be used for each individual wait strategy.

Examples

iex> config = RedisContainer.new()
iex> new_config = RedisContainer.with_wait_timeout(config, 8000)
iex> new_config.wait_timeout
8000