fix: missing eval of redis image from env var

This commit is contained in:
Manuel de la Peña
2025-05-23 10:20:28 +02:00
parent 5794b5068f
commit 1e6e787ec5

View File

@@ -1,6 +1,7 @@
package redis package redis
import ( import (
"os"
"testing" "testing"
"time" "time"
@@ -9,6 +10,12 @@ import (
testredis "github.com/gofiber/storage/testhelpers/redis" testredis "github.com/gofiber/storage/testhelpers/redis"
) )
const (
// redisImage is the default image used for running Redis in tests.
redisImage = "docker.io/redis:7"
redisImageEnvVar = "TEST_REDIS_IMAGE"
)
// newConfigFromContainer creates a Redis configuration using Testcontainers. // newConfigFromContainer creates a Redis configuration using Testcontainers.
// It configures the container based on the provided options and returns a Config // It configures the container based on the provided options and returns a Config
// that can be used to connect to the container. // that can be used to connect to the container.
@@ -16,6 +23,13 @@ import (
func newConfigFromContainer(t testing.TB, opts ...testredis.Option) Config { func newConfigFromContainer(t testing.TB, opts ...testredis.Option) Config {
t.Helper() t.Helper()
img := redisImage
if imgFromEnv := os.Getenv(redisImageEnvVar); imgFromEnv != "" {
img = imgFromEnv
}
opts = append(opts, testredis.WithImage(img))
redisCtr := testredis.Start(t, opts...) redisCtr := testredis.Start(t, opts...)
cfg := Config{ cfg := Config{