@@ -157,7 +157,7 @@ describe("backupRun.transition — status must not ride a payload that can fail"
157157const h = vi . hoisted ( ( ) => ( {
158158 run : null as Record < string , unknown > | null ,
159159 policy : null as Record < string , unknown > | null ,
160- services : [ ] as Array < { id : string ; enabled : boolean } > ,
160+ services : [ ] as Array < Record < string , unknown > > ,
161161 createdRuns : [ ] as Array < Record < string , unknown > > ,
162162 executionRow : null as Record < string , unknown > | null ,
163163 claimResults : [ "claimed" ] as Array < "claimed" | "project_unavailable" | "state_changed" > ,
@@ -360,8 +360,8 @@ describe("BackupOrchestrator.enqueue — durable batch identity", () => {
360360 mailServerId : null ,
361361 } ;
362362 h . services = [
363- { id : "svc_api" , enabled : true } ,
364- { id : "svc_db" , enabled : true } ,
363+ { id : "svc_api" , enabled : true , volumes : [ "api_data:/data" ] } ,
364+ { id : "svc_db" , enabled : true , image : "postgres:16" } ,
365365 ] ;
366366 const orchestrator = new BackupOrchestrator ( ) ;
367367
@@ -386,6 +386,75 @@ describe("BackupOrchestrator.enqueue — durable batch identity", () => {
386386 expect ( new Set ( secondBatch . map ( ( run ) => run . batchId ) ) . size ) . toBe ( 1 ) ;
387387 expect ( secondBatch [ 0 ] ! . batchId ) . not . toBe ( firstBatch [ 0 ] ! . batchId ) ;
388388 } ) ;
389+
390+ it ( "skips stateless services without volumes or database images during fan-out" , async ( ) => {
391+ h . policy = {
392+ ...( h . policy ?? { } ) ,
393+ sourceKind : "service" ,
394+ projectId : "proj_1" ,
395+ mailServerId : null ,
396+ payloadKind : "auto" ,
397+ } ;
398+ h . services = [
399+ { id : "svc_web" , enabled : true , volumes : [ ] } ,
400+ { id : "svc_monitor" , enabled : true , volumes : [ ] } ,
401+ { id : "svc_db" , enabled : true , image : "postgres:16" } ,
402+ ] ;
403+ const orchestrator = new BackupOrchestrator ( ) ;
404+
405+ await orchestrator . enqueue ( {
406+ policyId : "pol_1" ,
407+ trigger : { source : "cron" , userId : "system" } ,
408+ } ) ;
409+
410+ expect ( h . createdRuns ) . toHaveLength ( 1 ) ;
411+ expect ( h . createdRuns [ 0 ] ! . serviceId ) . toBe ( "svc_db" ) ;
412+ } ) ;
413+
414+ it ( "throws when project has no services with persistent storage" , async ( ) => {
415+ h . policy = {
416+ ...( h . policy ?? { } ) ,
417+ sourceKind : "service" ,
418+ projectId : "proj_1" ,
419+ mailServerId : null ,
420+ payloadKind : "auto" ,
421+ } ;
422+ h . services = [
423+ { id : "svc_web" , enabled : true , volumes : [ ] } ,
424+ { id : "svc_monitor" , enabled : true , volumes : [ ] } ,
425+ ] ;
426+ const orchestrator = new BackupOrchestrator ( ) ;
427+
428+ await expect (
429+ orchestrator . enqueue ( {
430+ policyId : "pol_1" ,
431+ trigger : { source : "cron" , userId : "system" } ,
432+ } ) ,
433+ ) . rejects . toThrow ( / n o s e r v i c e s w i t h p e r s i s t e n t s t o r a g e / ) ;
434+
435+ expect ( h . createdRuns ) . toHaveLength ( 0 ) ;
436+ } ) ;
437+
438+ it . each ( [ "custom_command" , "path" ] ) (
439+ "keeps explicit %s payloads eligible without volumes" ,
440+ async ( payloadKind ) => {
441+ h . policy = {
442+ ...( h . policy ?? { } ) ,
443+ sourceKind : "service" ,
444+ projectId : "proj_1" ,
445+ mailServerId : null ,
446+ payloadKind,
447+ } ;
448+ h . services = [ { id : "svc_app" , enabled : true , image : "node:22" , volumes : [ ] } ] ;
449+
450+ await new BackupOrchestrator ( ) . enqueue ( {
451+ policyId : "pol_1" ,
452+ trigger : { source : "cron" , userId : "system" } ,
453+ } ) ;
454+
455+ expect ( h . createdRuns . map ( ( run ) => run . serviceId ) ) . toEqual ( [ "svc_app" ] ) ;
456+ } ,
457+ ) ;
389458} ) ;
390459
391460describe ( "a terminal status is final — one owner per verdict" , ( ) => {
0 commit comments