Skip to content

Commit

Permalink
Introduce an option to specify Redis address for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erickskrauch committed Dec 8, 2023
1 parent 954d6d8 commit 830a719
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion db/redis/redis_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ package redis

import (
"fmt"
"os"
"reflect"
"strconv"
"testing"
"time"

Expand All @@ -16,7 +18,21 @@ import (
"github.com/elyby/chrly/model"
)

const redisAddr = "localhost:6379"
var redisAddr string

func init() {
host := "localhost"
port := 6379
if os.Getenv("STORAGE_REDIS_HOST") != "" {
host = os.Getenv("STORAGE_REDIS_HOST")
}

if os.Getenv("STORAGE_REDIS_PORT") != "" {
port, _ = strconv.Atoi(os.Getenv("STORAGE_REDIS_PORT"))
}

redisAddr = fmt.Sprintf("%s:%d", host, port)
}

func TestNew(t *testing.T) {
t.Run("should connect", func(t *testing.T) {
Expand Down

0 comments on commit 830a719

Please sign in to comment.