chore: support for overriding the redis image

This commit is contained in:
Manuel de la Peña
2025-04-30 13:18:19 +02:00
parent b90664baad
commit 76a7b0a657

View File

@@ -28,6 +28,10 @@ type Config struct {
UseAddress bool
UseHostPort bool
UseURL bool
// Image is the image to use for the Redis container
//
// Optional. Default is "docker.io/redis:7", but could be set to Valkey.
Image string
}
// Option is a function that configures a Config
@@ -63,6 +67,13 @@ func WithURL(useContainerURI bool) Option {
}
}
// WithImage sets the image to use for the Redis container
func WithImage(image string) Option {
return func(c *Config) {
c.Image = image
}
}
// Container represents a running Redis container
type Container struct {
URL string
@@ -88,6 +99,10 @@ func Start(t testing.TB, opts ...Option) *Container {
img = imgFromEnv
}
if config.Image != "" {
img = config.Image
}
ctx := context.Background()
tcOpts := []testcontainers.ContainerCustomizer{}