Current section
Files
Jump to
Current section
Files
src/testcontainers_gleam@redis.erl
-module(testcontainers_gleam@redis).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/testcontainers_gleam/redis.gleam").
-export([new/0, with_image/2, with_port/2, with_wait_timeout/2, with_check_image/2, with_reuse/2, build/1, default_image/0, port/1, connection_url/1]).
-export_type([redis_config/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Redis container configuration.\n"
"\n"
" Wraps `Testcontainers.RedisContainer` to provide typed builders\n"
" for a Redis container. Use `new` to create a default configuration,\n"
" customize with `with_*` functions, then `build` to get a `Container`.\n"
"\n"
" ## Example\n"
"\n"
" ```gleam\n"
" import testcontainers_gleam\n"
" import testcontainers_gleam/redis\n"
"\n"
" let config = redis.new()\n"
" let container = redis.build(config)\n"
" let assert Ok(running) = testcontainers_gleam.start_container(container)\n"
" let url = redis.connection_url(running)\n"
" ```\n"
).
-type redis_config() :: any().
-file("src/testcontainers_gleam/redis.gleam", 29).
?DOC(
" Create a new Redis container configuration with defaults.\n"
"\n"
" Default image: `redis:7.2-alpine`, port: 6379, timeout: 60s.\n"
).
-spec new() -> redis_config().
new() ->
'Elixir.Testcontainers.RedisContainer':new().
-file("src/testcontainers_gleam/redis.gleam", 33).
?DOC(" Override the Docker image.\n").
-spec with_image(redis_config(), binary()) -> redis_config().
with_image(Config, Image) ->
'Elixir.Testcontainers.RedisContainer':with_image(Config, Image).
-file("src/testcontainers_gleam/redis.gleam", 37).
?DOC(" Override the exposed port (default 6379).\n").
-spec with_port(redis_config(), integer()) -> redis_config().
with_port(Config, Port) ->
'Elixir.Testcontainers.RedisContainer':with_port(Config, Port).
-file("src/testcontainers_gleam/redis.gleam", 41).
?DOC(" Override the wait timeout in milliseconds (default 60000).\n").
-spec with_wait_timeout(redis_config(), integer()) -> redis_config().
with_wait_timeout(Config, Timeout) ->
'Elixir.Testcontainers.RedisContainer':with_wait_timeout(Config, Timeout).
-file("src/testcontainers_gleam/redis.gleam", 45).
?DOC(" Set the regex pattern to validate the image name.\n").
-spec with_check_image(redis_config(), binary()) -> redis_config().
with_check_image(Config, Pattern) ->
'Elixir.Testcontainers.RedisContainer':with_check_image(Config, Pattern).
-file("src/testcontainers_gleam/redis.gleam", 49).
?DOC(" Enable or disable container reuse across test runs.\n").
-spec with_reuse(redis_config(), boolean()) -> redis_config().
with_reuse(Config, Reuse) ->
'Elixir.Testcontainers.RedisContainer':with_reuse(Config, Reuse).
-file("src/testcontainers_gleam/redis.gleam", 52).
?DOC(" Build a `Container` from this Redis configuration.\n").
-spec build(redis_config()) -> testcontainers_gleam@container:container().
build(Config) ->
testcontainers_gleam_ffi:build_container(Config).
-file("src/testcontainers_gleam/redis.gleam", 58).
?DOC(" Get the default Docker image name (without tag).\n").
-spec default_image() -> binary().
default_image() ->
'Elixir.Testcontainers.RedisContainer':default_image().
-file("src/testcontainers_gleam/redis.gleam", 62).
?DOC(" Get the host-mapped port for the Redis container.\n").
-spec port(testcontainers_gleam@container:container()) -> integer().
port(Container) ->
'Elixir.Testcontainers.RedisContainer':port(Container).
-file("src/testcontainers_gleam/redis.gleam", 66).
?DOC(" Get the Redis connection URL (e.g. `\"redis://localhost:32768/\"`).\n").
-spec connection_url(testcontainers_gleam@container:container()) -> binary().
connection_url(Container) ->
'Elixir.Testcontainers.RedisContainer':connection_url(Container).