Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use serverless-redis-http to run adapter-upstash-redis tests locally #10033

Merged
merged 4 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/adapter-upstash-redis/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3"
services:
redis:
image: redis
ports:
- "6379:6379"
serverless-redis-http:
ports:
- "8079:80"
image: hiett/serverless-redis-http:latest
environment:
SRH_MODE: env
SRH_TOKEN: uwndz1YIfm9k78mx+mjW8qe7CX33VxRYnscDpZVkt4Y=
SRH_CONNECTION_STRING: "redis://redis:6379"
4 changes: 2 additions & 2 deletions packages/adapter-upstash-redis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"access": "public"
},
"scripts": {
"test": "vitest -c ../utils/vitest.config.ts",
"test": "./test/test.sh",
"build": "tsc"
},
"dependencies": {
Expand All @@ -48,4 +48,4 @@
"@upstash/redis": "^1.0.1",
"dotenv": "^10.0.0"
}
}
}
19 changes: 2 additions & 17 deletions packages/adapter-upstash-redis/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,9 @@ import { runBasicTests } from "utils/adapter"
import { hydrateDates, UpstashRedisAdapter } from "../src"
import "dotenv/config"

if (!process.env.UPSTASH_REDIS_URL || !process.env.UPSTASH_REDIS_KEY) {
test("Skipping UpstashRedisAdapter tests, since required environment variables aren't available", () => {
expect(true).toBe(true)
})
process.exit(0)
}

if (process.env.CI) {
// TODO: Fix this
test('Skipping UpstashRedisAdapter tests in CI because of "Request failed" errors. Should revisit', () => {
expect(true).toBe(true)
})
process.exit(0)
}

const client = new Redis({
url: process.env.UPSTASH_REDIS_URL,
token: process.env.UPSTASH_REDIS_KEY,
url: "http://localhost:8079",
token: "uwndz1YIfm9k78mx+mjW8qe7CX33VxRYnscDpZVkt4Y=",
})

runBasicTests({
Expand Down
16 changes: 16 additions & 0 deletions packages/adapter-upstash-redis/test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

echo "Initializing container for Upstash-Redis tests (Serverless-Redis-HTTP)"

# Init Redis + serverless-redis-http containers
docker compose up -d

echo "Waiting 10 sec for Redis to start..."
sleep 10

# Always stop container, but exit with 1 when tests are failing
if vitest -c ../utils/vitest.config.ts; then
docker compose down -v
else
docker compose down -v && exit 1
fi
Loading