Skip to content

Commit b0841ad

Browse files
committed
fix: tests and ci
1 parent 321ddec commit b0841ad

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ jobs:
5959
run: redis-cli config set notify-keyspace-events Exe
6060

6161
- name: Install Integration Test Project
62-
run: cd test/integration/next-app && pnpm install
62+
run: cd test/integration/next-app-15-3-2 && pnpm install
6363

6464
- name: Build Integration Test Project
65-
run: cd test/integration/next-app && pnpm build
65+
run: cd test/integration/next-app-15-3-2 && pnpm build
6666

6767
- name: Run tests
6868
run: pnpm test

src/ZodHandler.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* This handler is used to validate the arguments of the get, set, revalidateTag methods against a zod schema.
3+
* This is mainly used to test new nextjs versions and to ensure that the arguments are still valid. As we
4+
* saw in the past, that arguments against the cache handler changed between different nextjs versions very often (even between patch versions).
5+
*/
6+
7+
import RedisStringsHandler, {
8+
CreateRedisStringsHandlerOptions,
9+
} from './RedisStringsHandler';
10+
import { debugVerbose } from './utils/debug';
11+
12+
let cachedHandler: RedisStringsHandler;
13+
14+
export default class CachedHandler {
15+
constructor(options: CreateRedisStringsHandlerOptions) {
16+
if (!cachedHandler) {
17+
console.log('created cached handler');
18+
cachedHandler = new RedisStringsHandler(options);
19+
}
20+
}
21+
get(
22+
...args: Parameters<RedisStringsHandler['get']>
23+
): ReturnType<RedisStringsHandler['get']> {
24+
debugVerbose('CachedHandler.get called with', args);
25+
return cachedHandler.get(...args);
26+
}
27+
set(
28+
...args: Parameters<RedisStringsHandler['set']>
29+
): ReturnType<RedisStringsHandler['set']> {
30+
debugVerbose('CachedHandler.set called with', args);
31+
return cachedHandler.set(...args);
32+
}
33+
revalidateTag(
34+
...args: Parameters<RedisStringsHandler['revalidateTag']>
35+
): ReturnType<RedisStringsHandler['revalidateTag']> {
36+
debugVerbose('CachedHandler.revalidateTag called with', args);
37+
return cachedHandler.revalidateTag(...args);
38+
}
39+
resetRequestCache(
40+
...args: Parameters<RedisStringsHandler['resetRequestCache']>
41+
): ReturnType<RedisStringsHandler['resetRequestCache']> {
42+
// debug("CachedHandler.resetRequestCache called with", args);
43+
return cachedHandler.resetRequestCache(...args);
44+
}
45+
}

test/integration/nextjs-cache-handler.integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { join } from 'path';
66
import { CacheEntry } from '../../src/RedisStringsHandler';
77
import { revalidate as next1503_revalidatedFetch_route } from './next-app-15-0-3/src/app/api/revalidated-fetch/route';
88

9-
const NEXT_APP_DIR = join(__dirname, 'next-app-15-0-3');
10-
// const NEXT_APP_DIR = join(__dirname, 'next-app-15-3-2');
9+
// const NEXT_APP_DIR = join(__dirname, 'next-app-15-0-3');
10+
const NEXT_APP_DIR = join(__dirname, 'next-app-15-3-2');
1111
console.log('NEXT_APP_DIR', NEXT_APP_DIR);
1212
const NEXT_START_PORT = 3055;
1313
const NEXT_START_URL = `http://localhost:${NEXT_START_PORT}`;

0 commit comments

Comments
 (0)