Skip to content

Commit ae43273

Browse files
committed
chore: Update test scripts in package.json and CI workflow to include unit and integration tests
1 parent f6ae097 commit ae43273

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Run library tests
4242
run: |
4343
npm ci
44-
npm run test:lib
44+
npm run test:unit
4545
test-integration:
4646
name: Test (Integration)
4747
needs: [test-library]
@@ -67,7 +67,7 @@ jobs:
6767
- name: Run integration tests
6868
run: |
6969
npm ci
70-
npm run test:lib
70+
npm run test:integration
7171
env:
7272
REDIS_PORT: 6379
7373
REDIS_CLUSTER_PORT: 7000

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
"format:code": "xo --fix",
4747
"format:rest": "prettier --write .",
4848
"format": "run-s format:*",
49+
"test:unit": "jest test/store-test.ts",
50+
"test:integration": "jest test/redis-integration-test.ts",
4951
"test:lib": "jest",
50-
"test": "run-s lint test:*",
52+
"test": "run-s lint test:lib",
5153
"pre-commit": "lint-staged",
5254
"prepare": "run-s compile && husky install config/husky"
5355
},

test/redis-integration-test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ describe('Redis Integration Tests', () => {
148148
store = new RedisStore({
149149
async sendCommandCluster(details: SendCommandClusterDetails) {
150150
const { command } = details
151+
152+
// If SCRIPT LOAD, send to all master nodes
153+
if (command[0] === 'SCRIPT' && command[1] === 'LOAD') {
154+
const nodes = client.nodes('master')
155+
await Promise.all(
156+
nodes.map(async (node) =>
157+
node.call(command[0], ...command.slice(1)),
158+
),
159+
)
160+
// Return the result from one of them (they should be identical)
161+
const result = await client.call(command[0], ...command.slice(1))
162+
return result as RedisReply
163+
}
164+
151165
const result = await client.call(command[0], ...command.slice(1))
152166
return result as RedisReply
153167
},
@@ -203,6 +217,19 @@ describe('Redis Integration Tests', () => {
203217
const shortStore = new RedisStore({
204218
async sendCommandCluster(details: SendCommandClusterDetails) {
205219
const { command } = details
220+
221+
// If SCRIPT LOAD, send to all master nodes
222+
if (command[0] === 'SCRIPT' && command[1] === 'LOAD') {
223+
const nodes = client.nodes('master')
224+
await Promise.all(
225+
nodes.map(async (node) =>
226+
node.call(command[0], ...command.slice(1)),
227+
),
228+
)
229+
const result = await client.call(command[0], ...command.slice(1))
230+
return result as RedisReply
231+
}
232+
206233
const result = await client.call(command[0], ...command.slice(1))
207234
return result as RedisReply
208235
},

0 commit comments

Comments
 (0)