Personal Telegram developer console for GitHub
test: require production durable object binding
davoodmehraban89 committed
Oct 3, 2026 at 07:14 UTC
3cbb732003801427c01cb124438bf1ade10392f8
1 file changed
+18
test/durable-replay.test.js
+18
@@ -1,5 +1,7 @@
1
import test from 'node:test';
2
import assert from 'node:assert/strict';
3
+import { readFile } from 'node:fs/promises';
4
+import worker, { ApprovalReplayGuard as ExportedApprovalReplayGuard } from '../src/index.js';
5
import { DurableApprovalReplayStore } from '../src/core/durable-replay-store.js';
6
import { ApprovalReplayGuard } from '../src/durable/approval-replay-guard.js';
7
@@ -111,3 +113,19 @@ test('ApprovalReplayGuard fails closed for expired requests and alarm removes st
113
await guard.alarm();
114
assert.equal(state.data.size, 0);
115
});
116
+
117
+test('Worker exports ApprovalReplayGuard and Wrangler declares SQLite durable binding', async () => {
118
+ assert.ok(worker && typeof worker.fetch === 'function');
119
+ assert.equal(ExportedApprovalReplayGuard, ApprovalReplayGuard);
120
+
121
+ const configText = await readFile(new URL('../wrangler.jsonc', import.meta.url), 'utf8');
122
+ const config = JSON.parse(configText);
123
+ assert.deepEqual(config.durable_objects?.bindings, [{
124
+ name: 'APPROVAL_REPLAY_GUARD',
125
+ class_name: 'ApprovalReplayGuard'
126
+ }]);
127
+ assert.deepEqual(config.exports?.ApprovalReplayGuard, {
128
+ type: 'durable-object',
129
+ storage: 'sqlite'
130
+ });
131
+});