@@ -15,7 +15,7 @@ vi.mock('./context', async (importOriginal) => {
1515} )
1616
1717import { type CheckContext , loadCheckContext , runChecks } from './checks'
18- import type { EnvFile , EnvTarget } from './env-files'
18+ import { type EnvFile , type EnvTarget , parseEnv } from './env-files'
1919
2020function envFile ( target : EnvTarget , values : Record < string , string > = { } ) : EnvFile {
2121 return {
@@ -126,18 +126,22 @@ describe('doctor --fix on env files', () => {
126126 expect ( readFileSync ( files . db , 'utf8' ) ) . toBe ( dbFile )
127127 } )
128128
129- it ( 'leaves a shared secret it cannot copy unset rather than generating a different one' , async ( ) => {
130- const secret = `BETTER_AUTH_SECRET=\${AUTH_SECRET_BASE}0123456789abcdef0123456789abcdef`
131- writeFiles ( {
132- sim : `${ secret } \n` ,
133- realtime : 'DATABASE_URL=postgresql://localhost/sim\n' ,
134- db : '' ,
135- } )
136-
137- for ( const finding of await runChecks ( loadCheckContext ( false ) , [ 'schema' ] ) ) finding . autofix ?.( )
138-
139- expect ( readFileSync ( files . realtime , 'utf8' ) ) . not . toContain ( 'BETTER_AUTH_SECRET' )
140- } )
129+ it . each ( [
130+ [ 'missing' , 'DATABASE_URL=postgresql://localhost/sim\n' ] ,
131+ [ 'a placeholder' , 'BETTER_AUTH_SECRET=your_auth_secret_here\n' ] ,
132+ ] ) (
133+ 'never generates a shared secret it cannot copy when realtime has it %s' ,
134+ async ( _ , realtime ) => {
135+ const secret = `BETTER_AUTH_SECRET=\${AUTH_SECRET_BASE}0123456789abcdef0123456789abcdef`
136+ writeFiles ( { sim : `${ secret } \n` , realtime, db : '' } )
137+
138+ for ( const finding of await runChecks ( loadCheckContext ( false ) , [ 'schema' ] ) )
139+ finding . autofix ?.( )
140+
141+ const after = parseEnv ( readFileSync ( files . realtime , 'utf8' ) ) . get ( 'BETTER_AUTH_SECRET' )
142+ expect ( after ) . toBe ( parseEnv ( realtime ) . get ( 'BETTER_AUTH_SECRET' ) )
143+ }
144+ )
141145
142146 it ( 'reports a value it cannot write instead of aborting the other fixes' , async ( ) => {
143147 const unwritable = 'DATABASE_URL="postgresql://u:p\\$x\\y@localhost/sim"\n'
0 commit comments