@@ -18,7 +18,13 @@ import { afterEach, describe, expect, it } from "bun:test";
1818import { mkdirSync , mkdtempSync , rmSync , writeFileSync } from "node:fs" ;
1919import { tmpdir } from "node:os" ;
2020import { join } from "node:path" ;
21- import type { AssembleResult , ChunkResult , PlanResult } from "@hyperframes/producer/distributed" ;
21+ import {
22+ CURRENT_PLAN_PROTOCOL ,
23+ PlanProtocolUnsupportedError ,
24+ type AssembleResult ,
25+ type ChunkResult ,
26+ type PlanResult ,
27+ } from "@hyperframes/producer/distributed" ;
2228import { asStorage , FakeGcs } from "./__fixtures__/fakeGcs.js" ;
2329import type { AssembleEvent , CloudRunEvent , PlanEvent , RenderChunkEvent } from "./events.js" ;
2430import { createApp , dispatch , type HandlerDeps , unwrapEvent } from "./server.js" ;
@@ -56,6 +62,7 @@ async function seedPlanTar(gcs: FakeGcs, uri: string, planHash: string): Promise
5662
5763const planResult : PlanResult = {
5864 planDir : "(set at call time)" ,
65+ planProtocol : CURRENT_PLAN_PROTOCOL ,
5966 planHash : PLAN_HASH ,
6067 chunkCount : 3 ,
6168 totalFrames : 90 ,
@@ -295,6 +302,34 @@ describe("createApp HTTP mapping", () => {
295302 expect ( body . error ) . toBe ( "PLAN_HASH_MISMATCH" ) ;
296303 } ) ;
297304
305+ it ( "returns 400 for an unsupported plan protocol" , async ( ) => {
306+ const gcs = new FakeGcs ( ) ;
307+ await seedPlanTar ( gcs , "gs://b/renders/r1/plan.tar.gz" , PLAN_HASH ) ;
308+ const app = createApp (
309+ depsWith ( gcs , {
310+ renderChunk : async ( ) => {
311+ throw new PlanProtocolUnsupportedError ( "unsupported test protocol" ) ;
312+ } ,
313+ } ) ,
314+ ) ;
315+ const res = await app . request ( "/" , {
316+ method : "POST" ,
317+ headers : { "content-type" : "application/json" } ,
318+ body : JSON . stringify ( {
319+ Action : "renderChunk" ,
320+ PlanGcsUri : "gs://b/renders/r1/plan.tar.gz" ,
321+ PlanHash : PLAN_HASH ,
322+ ChunkIndex : 0 ,
323+ ChunkOutputGcsPrefix : "gs://b/renders/r1/" ,
324+ Format : "mp4" ,
325+ } ) ,
326+ } ) ;
327+
328+ expect ( res . status ) . toBe ( 400 ) ;
329+ const body = ( await res . json ( ) ) as { error : string } ;
330+ expect ( body . error ) . toBe ( "PlanProtocolUnsupportedError" ) ;
331+ } ) ;
332+
298333 it ( "returns 500 for a retryable/unknown error" , async ( ) => {
299334 const gcs = new FakeGcs ( ) ; // plan tar NOT seeded → download fails (retryable)
300335 const app = createApp ( depsWith ( gcs ) ) ;
0 commit comments