fixup! diigo-cache: diigo counts pages from 0; migrate stored pages (schema v2)
Docs per the docs-files-api skill: a 1–2 line @file; what a declaration is or does in JSDoc on it, not in // comments or the file header. Generated-by: Claude Opus 5.5
This commit is contained in:
1 parent
2a7d0ae0cb
commit
2bb18a9e96
2 files changed
+10
-14
No files matched your search
@@ -1,11 +1,4 @@
|
|||||||
/**
|
/** @file a stand-in for webapp's `WebAppFactory`, serving diigo-shaped pages to tests. */
|
||||||
* @file a stand-in for webapp's `WebAppFactory` entrypoint, for tests: an
|
|
||||||
* auxiliary worker (plain JS — the vitest pool doesn't transform aux
|
|
||||||
* workers) serving diigo-shaped `load_user_items` pages. 250 items (3
|
|
||||||
* pages of 100, the last short), every third private; a few webapp ids
|
|
||||||
* are known. Counts its diigo calls so tests
|
|
||||||
* can tell a cache hit (no call) from a miss.
|
|
||||||
*/
|
|
||||||
import { RpcTarget, WorkerEntrypoint } from "cloudflare:workers";
|
import { RpcTarget, WorkerEntrypoint } from "cloudflare:workers";
|
||||||
|
|
||||||
const KNOWN_WEBAPP = "fake-webapp-id";
|
const KNOWN_WEBAPP = "fake-webapp-id";
|
||||||
@@ -106,6 +99,12 @@ class FakeGet extends RpcTarget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* webapp's `WebAppFactory` entrypoint, faked: an auxiliary worker (plain
|
||||||
|
* JS; the vitest pool doesn't transform aux workers) serving
|
||||||
|
* `load_user_items` pages for a few known webapp ids. Counts its diigo
|
||||||
|
* calls, so tests can tell a cache hit (no call) from a miss.
|
||||||
|
*/
|
||||||
export class WebAppFactory extends WorkerEntrypoint {
|
export class WebAppFactory extends WorkerEntrypoint {
|
||||||
async at(id) {
|
async at(id) {
|
||||||
const kind = {
|
const kind = {
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
/**
|
/** @file the tests' main module: the real worker plus a fixed-clock cache. */
|
||||||
* @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 { DiigoCacheLogic } from "../src/cache.js";
|
import { DiigoCacheLogic } from "../src/cache.js";
|
||||||
import type { CacheEnv } from "../src/cache.js";
|
import type { CacheEnv } from "../src/cache.js";
|
||||||
|
|
||||||
@@ -13,7 +9,8 @@ export { default } from "../src/index.js";
|
|||||||
* never due in real time — tests run it with runDurableObjectAlarm */
|
* never due in real time — tests run it with runDurableObjectAlarm */
|
||||||
export const FIXED_NOW = Date.UTC(2099, 0, 1, 0, 0, 0);
|
export const FIXED_NOW = Date.UTC(2099, 0, 1, 0, 0, 0);
|
||||||
|
|
||||||
/** a fixed clock that records each sleep it is asked for */
|
/** the private cache's logic on a fixed clock that records each sleep it
|
||||||
|
* is asked for (bound as CLOCKED_DO in wrangler.tests.jsonc) */
|
||||||
export class FixedClockCache extends DiigoCacheLogic {
|
export class FixedClockCache extends DiigoCacheLogic {
|
||||||
#sleeps: number[] = [];
|
#sleeps: number[] = [];
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user