diff options
-rw-r--r-- | backend/.github/workflows/go.yaml | 17 | ||||
-rw-r--r-- | backend/internal/redis/taskqueue/queue_test.go | 18 |
2 files changed, 30 insertions, 5 deletions
diff --git a/backend/.github/workflows/go.yaml b/backend/.github/workflows/go.yaml index d886005..fe1b3a1 100644 --- a/backend/.github/workflows/go.yaml +++ b/backend/.github/workflows/go.yaml @@ -13,8 +13,19 @@ jobs: build: runs-on: ubuntu-latest + services: + redis: + image: redis + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive token: ${{ secrets.PAT_TOKEN }} @@ -32,12 +43,14 @@ jobs: run: go build -v ./... - name: Test run: go test -v ./... + env: + REDIS_ADDR: "localhost:6379" lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive token: ${{ secrets.PAT_TOKEN }} diff --git a/backend/internal/redis/taskqueue/queue_test.go b/backend/internal/redis/taskqueue/queue_test.go index b54d22a..aa817c5 100644 --- a/backend/internal/redis/taskqueue/queue_test.go +++ b/backend/internal/redis/taskqueue/queue_test.go @@ -3,6 +3,7 @@ package taskqueue import ( "context" "errors" + "os" "testing" "time" @@ -11,12 +12,23 @@ import ( "github.com/stretchr/testify/require" ) +func getRedisClient() *redis.Client { + addr := os.Getenv("REDIS_ADDR") + if addr == "" { + addr = "localhost:6379" + } + + return redis.NewClient(&redis.Options{ + Addr: addr, + }) +} + func TestTaskQueue(t *testing.T) { if testing.Short() { t.Skip() } - client := redis.NewClient(new(redis.Options)) + client := getRedisClient() defer func(client *redis.Client) { _ = client.Close() }(client) @@ -202,7 +214,7 @@ func TestTaskQueue_List(t *testing.T) { t.Skip() } - client := redis.NewClient(new(redis.Options)) + client := getRedisClient() defer func(client *redis.Client) { _ = client.Close() }(client) @@ -371,7 +383,7 @@ func TestTaskQueue_Return(t *testing.T) { t.Skip() } - client := redis.NewClient(new(redis.Options)) + client := getRedisClient() defer func(client *redis.Client) { _ = client.Close() }(client) |