@@ -217,19 +217,27 @@ describe('evaluateInjectedEnvReuse', () => {
217217 expect ( decision ) . toMatchObject ( { reuse : false , reason : expect . stringContaining ( 'fingerprint' ) } ) ;
218218 } ) ;
219219
220- test ( 'a changed disabled source does not block reuse' , ( ) => {
221- // a disabled file cannot affect resolved values; whatever disabled it is ambient
222- // env, which the env-drift check covers separately
223- const source = writeSourceFile ( '.env.production' , 'FOO=prod-val\n' ) ;
220+ test ( 'an unchanged disabled source does not block reuse' , ( ) => {
221+ const source = writeSourceFile ( '.env.production' , '# @disable\nFOO=prod-val\n' ) ;
224222 source . enabled = false ;
225- fs . writeFileSync ( path . join ( tempDir , '.env.production' ) , 'FOO=edited\n' ) ;
226223 const decision = evaluateInjectedEnvReuse ( {
227224 env : { __VARLOCK_ENV : makeBlob ( { sources : [ source ] } ) } ,
228225 cwd : tempDir ,
229226 } ) ;
230227 expect ( decision . reuse ) . toBe ( true ) ;
231228 } ) ;
232229
230+ test ( 'a changed disabled source blocks reuse (editing can remove @disable)' , ( ) => {
231+ const source = writeSourceFile ( '.env.production' , '# @disable\nFOO=prod-val\n' ) ;
232+ source . enabled = false ;
233+ fs . writeFileSync ( path . join ( tempDir , '.env.production' ) , 'FOO=prod-val\n' ) ;
234+ const decision = evaluateInjectedEnvReuse ( {
235+ env : { __VARLOCK_ENV : makeBlob ( { sources : [ source ] } ) } ,
236+ cwd : tempDir ,
237+ } ) ;
238+ expect ( decision ) . toMatchObject ( { reuse : false , reason : expect . stringContaining ( 'changed since' ) } ) ;
239+ } ) ;
240+
233241 test ( 'non-file sources (no path) are skipped' , ( ) => {
234242 const decision = evaluateInjectedEnvReuse ( {
235243 env : { __VARLOCK_ENV : makeBlob ( { sources : [ { type : 'processEnv' , label : 'process env' , enabled : true } ] } ) } ,
0 commit comments