Files
sigil/test/s05-not-found.test.ts
T
xiaoju f20b19a71e feat: implement Sigil Phase 1 MVP 🔮
- Wrangler project setup (TypeScript + Vitest)
- SigilBackend interface + WorkerPool implementation
- KV store with layered key schema (code/meta/lru/route/auth/stats)
- LRU scheduler with eviction priority (ephemeral_expired > ephemeral > normal > persistent)
- AuthModule: Bearer token validation, agent isolation, deploy cooldown
- Router: /_health, /_api/deploy, /_api/remove, /_api/list, /_api/inspect, /{agent}/{capability}
- 13 test scenarios, all passing (38 tests)
- MockKV + MockCfApi for isolated testing

Tests: 38/38  | Build: 22KB gzip:5KB 

小橘 🍊(NEKO Team)
2026-04-03 04:17:43 +00:00

35 lines
1.2 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest'
import { createMockKv, createMockCfApi } from './setup.js'
import { WorkerPool } from '../src/backend/worker-pool.js'
describe('S5: 调用不存在的能力', () => {
let mockKv: KVNamespace
let mockCf: ReturnType<typeof createMockCfApi>
let pool: WorkerPool
beforeEach(() => {
mockKv = createMockKv()
mockCf = createMockCfApi()
pool = new WorkerPool(mockKv, mockCf.cfApi)
})
it('should return 404 for nonexistent capability', async () => {
const req = new Request('https://sigil.shazhou.workers.dev/xiaoju/nonexistent')
const resp = await pool.invoke('xiaoju--nonexistent', req)
expect(resp.status).toBe(404)
})
it('should return error JSON body', async () => {
const req = new Request('https://sigil.shazhou.workers.dev/xiaoju/nonexistent')
const resp = await pool.invoke('xiaoju--nonexistent', req)
const body = await resp.json() as { error: string }
expect(body.error).toBeTruthy()
})
it('should not call deployWorker for nonexistent', async () => {
const req = new Request('https://sigil.shazhou.workers.dev/xiaoju/nonexistent')
await pool.invoke('xiaoju--nonexistent', req)
expect(mockCf.deployCalls()).toHaveLength(0)
})
})