fixup! diigo-cache: the caches take their clock as a constructor argument
Past the transitional idiom: the cache logic (DiigoCacheLogic, PublicCacheLogic in cache.ts) requires its Clock, with no default, so cache.ts reaches no ambient time. The worker's entry module is the edge: it makes the live clock and exports the runtime-constructed DiigoCache/PublicCache as (ctx, env) subclasses that supply it (the Cloudflare constraint: the runtime constructs DOs with ctx and env only). Binding class names are unchanged, so stored state is too. The tests' FixedClockCache extends the logic class. Generated-by: Claude Opus 5.5
This commit is contained in:
1 parent
cf901ded5f
commit
961515d8db
6 files changed
+53
-31
No files matched your search
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* @file the tests' main module: the real worker, plus a DiigoCache on a
|
||||
* fixed clock (bound as CLOCKED_DO in wrangler.tests.jsonc), so tests can
|
||||
* interpose time through the constructor.
|
||||
* @file the tests' main module — their edge: the real worker (whose own
|
||||
* edge supplies the live clock), plus the private cache's logic on a fixed
|
||||
* clock (bound as CLOCKED_DO in wrangler.tests.jsonc).
|
||||
*/
|
||||
import { DiigoCache } from "../src/cache.js";
|
||||
import { DiigoCacheLogic } from "../src/cache.js";
|
||||
import type { CacheEnv } from "../src/cache.js";
|
||||
|
||||
export * from "../src/index.js";
|
||||
@@ -12,7 +12,7 @@ export { default } from "../src/index.js";
|
||||
/** 2026-10-07T12:00:00Z */
|
||||
export const FIXED_NOW = Date.UTC(2026, 9, 7, 12, 0, 0);
|
||||
|
||||
export class FixedClockCache extends DiigoCache {
|
||||
export class FixedClockCache extends DiigoCacheLogic {
|
||||
constructor(ctx: DurableObjectState, env: CacheEnv) {
|
||||
super(ctx, env, { now: () => FIXED_NOW, sleep: async () => {} });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user