mirror of
https://github.com/gofiber/storage.git
synced 2025-10-08 18:11:23 +08:00
fix: missing eval of redis image from env var
This commit is contained in:
@@ -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{
|
||||||
|
Reference in New Issue
Block a user