@@ -12,7 +12,10 @@ import {
1212
1313vi . setConfig ( { testTimeout : 60_000 } ) ;
1414
15- async function authEnv ( prisma : PrismaClient , environmentId : string ) : Promise < AuthenticatedEnvironment > {
15+ async function authEnv (
16+ prisma : PrismaClient ,
17+ environmentId : string
18+ ) : Promise < AuthenticatedEnvironment > {
1619 const row = await prisma . runtimeEnvironment . findFirstOrThrow ( {
1720 where : { id : environmentId } ,
1821 include : authIncludeBase ,
@@ -61,29 +64,30 @@ describe("PauseEnvironmentService", () => {
6164 }
6265 ) ;
6366
64- postgresTest ( "rejects resume of a billing-limit paused env and leaves it paused" , async ( {
65- prisma,
66- } ) => {
67- const { environment } = await seedProductionEnv ( prisma ) ;
68- await prisma . runtimeEnvironment . update ( {
69- where : { id : environment . id } ,
70- data : { paused : true , pauseSource : EnvironmentPauseSource . BILLING_LIMIT } ,
71- } ) ;
72-
73- const service = new PauseEnvironmentService ( prisma ) ;
74- const env = await authEnv ( prisma , environment . id ) ;
75-
76- const result = await service . call ( env , "resumed" ) ;
77- expect ( result . success ) . toBe ( false ) ;
78- if ( result . success ) return ;
79- expect ( result . error ) . toContain ( "billing limit" ) ;
80-
81- const after = await prisma . runtimeEnvironment . findFirstOrThrow ( {
82- where : { id : environment . id } ,
83- } ) ;
84- expect ( after . paused ) . toBe ( true ) ;
85- expect ( after . pauseSource ) . toBe ( EnvironmentPauseSource . BILLING_LIMIT ) ;
86- } ) ;
67+ postgresTest (
68+ "rejects resume of a billing-limit paused env and leaves it paused" ,
69+ async ( { prisma } ) => {
70+ const { environment } = await seedProductionEnv ( prisma ) ;
71+ await prisma . runtimeEnvironment . update ( {
72+ where : { id : environment . id } ,
73+ data : { paused : true , pauseSource : EnvironmentPauseSource . BILLING_LIMIT } ,
74+ } ) ;
75+
76+ const service = new PauseEnvironmentService ( prisma ) ;
77+ const env = await authEnv ( prisma , environment . id ) ;
78+
79+ const result = await service . call ( env , "resumed" ) ;
80+ expect ( result . success ) . toBe ( false ) ;
81+ if ( result . success ) return ;
82+ expect ( result . error ) . toContain ( "billing limit" ) ;
83+
84+ const after = await prisma . runtimeEnvironment . findFirstOrThrow ( {
85+ where : { id : environment . id } ,
86+ } ) ;
87+ expect ( after . paused ) . toBe ( true ) ;
88+ expect ( after . pauseSource ) . toBe ( EnvironmentPauseSource . BILLING_LIMIT ) ;
89+ }
90+ ) ;
8791
8892 postgresTest (
8993 "manual pause while billing-limit paused is a no-op that preserves pauseSource" ,
0 commit comments