@@ -88,4 +88,63 @@ describe('#tools deploy dry-run modes', () => {
8888 sinon . assert . calledOnceWithExactly ( dryRunStub , { interactive : false } ) ;
8989 sinon . assert . notCalled ( processChangesStub ) ;
9090 } ) ;
91+
92+ it ( 'should throw before validate when AUTH0_DRY_RUN is an invalid value' , async ( ) => {
93+ const validateStub = sandbox . stub ( Auth0 . prototype , 'validate' ) . resolves ( ) ;
94+ sandbox . stub ( Auth0 . prototype , 'processChanges' ) . resolves ( ) ;
95+
96+ const config = buildConfig ( { AUTH0_DRY_RUN : 'not-a-mode' } ) ;
97+
98+ try {
99+ await deploy ( { } , { } as any , config ) ;
100+ throw new Error ( 'Expected deploy to throw' ) ;
101+ } catch ( err ) {
102+ sinon . assert . notCalled ( validateStub ) ;
103+ if ( ( err as Error ) . message === 'Expected deploy to throw' ) throw err ;
104+ }
105+ } ) ;
106+
107+ it ( 'should call processChanges and return handler summary when dry-run is not set' , async ( ) => {
108+ sandbox . stub ( Auth0 . prototype , 'validate' ) . resolves ( ) ;
109+ const dryRunStub = sandbox . stub ( Auth0 . prototype , 'dryRun' ) . resolves ( true ) ;
110+ const processChangesStub = sandbox . stub ( Auth0 . prototype , 'processChanges' ) . resolves ( ) ;
111+
112+ const config = buildConfig ( { } ) ;
113+ const result = await deploy ( { } , { } as any , config ) ;
114+
115+ sinon . assert . notCalled ( dryRunStub ) ;
116+ sinon . assert . calledOnce ( processChangesStub ) ;
117+ sinon . assert . match ( result , sinon . match . object ) ;
118+ } ) ;
119+
120+ it ( 'should pass interactive=true to dryRun when AUTH0_DRY_RUN_INTERACTIVE is set' , async ( ) => {
121+ sandbox . stub ( Auth0 . prototype , 'validate' ) . resolves ( ) ;
122+ const dryRunStub = sandbox . stub ( Auth0 . prototype , 'dryRun' ) . resolves ( false ) ;
123+ sandbox . stub ( Auth0 . prototype , 'processChanges' ) . resolves ( ) ;
124+
125+ const config = buildConfig ( {
126+ AUTH0_DRY_RUN : 'preview' ,
127+ AUTH0_DRY_RUN_INTERACTIVE : true ,
128+ AUTH0_DRY_RUN_APPLY : false ,
129+ } ) ;
130+
131+ await deploy ( { } , { } as any , config ) ;
132+
133+ sinon . assert . calledOnceWithExactly ( dryRunStub , { interactive : true } ) ;
134+ } ) ;
135+
136+ it ( 'should normalize AUTH0_DRY_RUN=true (boolean) to preview mode' , async ( ) => {
137+ sandbox . stub ( Auth0 . prototype , 'validate' ) . resolves ( ) ;
138+ const dryRunStub = sandbox . stub ( Auth0 . prototype , 'dryRun' ) . resolves ( false ) ;
139+ sandbox . stub ( Auth0 . prototype , 'processChanges' ) . resolves ( ) ;
140+
141+ const config = buildConfig ( {
142+ AUTH0_DRY_RUN : true ,
143+ AUTH0_DRY_RUN_INTERACTIVE : false ,
144+ } ) ;
145+
146+ await deploy ( { } , { } as any , config ) ;
147+
148+ sinon . assert . calledOnceWithExactly ( dryRunStub , { interactive : false } ) ;
149+ } ) ;
91150} ) ;
0 commit comments