Skip to content

Commit a7e3c72

Browse files
authored
fix: use serverless-redis-http to run adapter-upstash-redis tests locally (#10033)
1 parent 46b88b1 commit a7e3c72

File tree

4 files changed

+34
-19
lines changed

4 files changed

+34
-19
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: "3"
2+
services:
3+
redis:
4+
image: redis
5+
ports:
6+
- "6379:6379"
7+
serverless-redis-http:
8+
ports:
9+
- "8079:80"
10+
image: hiett/serverless-redis-http:latest
11+
environment:
12+
SRH_MODE: env
13+
SRH_TOKEN: uwndz1YIfm9k78mx+mjW8qe7CX33VxRYnscDpZVkt4Y=
14+
SRH_CONNECTION_STRING: "redis://redis:6379"

packages/adapter-upstash-redis/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"access": "public"
3535
},
3636
"scripts": {
37-
"test": "vitest -c ../utils/vitest.config.ts",
37+
"test": "./test/test.sh",
3838
"build": "tsc"
3939
},
4040
"dependencies": {
@@ -48,4 +48,4 @@
4848
"@upstash/redis": "^1.0.1",
4949
"dotenv": "^10.0.0"
5050
}
51-
}
51+
}

packages/adapter-upstash-redis/test/index.test.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,9 @@ import { runBasicTests } from "utils/adapter"
33
import { hydrateDates, UpstashRedisAdapter } from "../src"
44
import "dotenv/config"
55

6-
if (!process.env.UPSTASH_REDIS_URL || !process.env.UPSTASH_REDIS_KEY) {
7-
test("Skipping UpstashRedisAdapter tests, since required environment variables aren't available", () => {
8-
expect(true).toBe(true)
9-
})
10-
process.exit(0)
11-
}
12-
13-
if (process.env.CI) {
14-
// TODO: Fix this
15-
test('Skipping UpstashRedisAdapter tests in CI because of "Request failed" errors. Should revisit', () => {
16-
expect(true).toBe(true)
17-
})
18-
process.exit(0)
19-
}
20-
216
const client = new Redis({
22-
url: process.env.UPSTASH_REDIS_URL,
23-
token: process.env.UPSTASH_REDIS_KEY,
7+
url: "http://localhost:8079",
8+
token: "uwndz1YIfm9k78mx+mjW8qe7CX33VxRYnscDpZVkt4Y=",
249
})
2510

2611
runBasicTests({
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
echo "Initializing container for Upstash-Redis tests (Serverless-Redis-HTTP)"
4+
5+
# Init Redis + serverless-redis-http containers
6+
docker compose up -d
7+
8+
echo "Waiting 10 sec for Redis to start..."
9+
sleep 10
10+
11+
# Always stop container, but exit with 1 when tests are failing
12+
if vitest -c ../utils/vitest.config.ts; then
13+
docker compose down -v
14+
else
15+
docker compose down -v && exit 1
16+
fi

0 commit comments

Comments
 (0)