e86bae8d4a
Root cause: CF blocks Worker-to-Worker fetch on workers.dev (error 1042). Gateway Worker could not proxy requests to child worker subdomains. Fix: Replace CF API worker scripts with Dynamic Workers (LOADER binding). - deploy() writes code to KV only, no CF API calls - invoke() uses LOADER.get(id, fn) to execute code inline - remove() clears KV only, no CF API delete - Removed cf-api.ts, slot management, subdomain routing - 67/67 tests passing, production verified Reported-by: 小墨 🖊️ (KUMA) 小橘 🍊(NEKO Team)
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest'
|
|
import { createMockKv, createMockLoader, MockEmbeddingService } from './setup.js'
|
|
import { WorkerPool } from '../src/backend/worker-pool.js'
|
|
|
|
describe('S5: 调用不存在的能力', () => {
|
|
let mockKv: KVNamespace
|
|
let mockLoader: ReturnType<typeof createMockLoader>
|
|
let mockEmbed: MockEmbeddingService
|
|
let pool: WorkerPool
|
|
|
|
beforeEach(() => {
|
|
mockKv = createMockKv()
|
|
mockLoader = createMockLoader()
|
|
mockEmbed = new MockEmbeddingService()
|
|
pool = new WorkerPool(mockKv, mockLoader.loader, mockEmbed as any)
|
|
})
|
|
|
|
it('should return 404 for nonexistent capability', async () => {
|
|
const req = new Request('https://sigil.shazhou.workers.dev/run/nonexistent')
|
|
const resp = await pool.invoke('nonexistent', req)
|
|
expect(resp.status).toBe(404)
|
|
})
|
|
|
|
it('should return error JSON body', async () => {
|
|
const req = new Request('https://sigil.shazhou.workers.dev/run/nonexistent')
|
|
const resp = await pool.invoke('nonexistent', req)
|
|
const body = await resp.json() as { error: string }
|
|
expect(body.error).toBeTruthy()
|
|
})
|
|
|
|
it('should not call LOADER.get for nonexistent capability', async () => {
|
|
const req = new Request('https://sigil.shazhou.workers.dev/run/nonexistent')
|
|
await pool.invoke('nonexistent', req)
|
|
expect(mockLoader.loaderCalls()).toHaveLength(0)
|
|
})
|
|
})
|