@@ -4,10 +4,6 @@ import { Flow } from '@pgflow/dsl';
44import { delay } from '@std/async' ;
55import { createFlowWorker } from '../../../src/flow/createFlowWorker.ts' ;
66import { createTestPlatformAdapter } from '../_helpers.ts' ;
7- import {
8- KNOWN_LOCAL_ANON_KEY ,
9- KNOWN_LOCAL_SERVICE_ROLE_KEY ,
10- } from '../../../src/shared/localDetection.ts' ;
117import type { postgres } from '../../sql.ts' ;
128
139// Define a minimal test flow
@@ -17,17 +13,6 @@ const TestCompilationFlow = new Flow<{ value: number }>({ slug: 'test_compilatio
1713 return input . run . value * 2 ;
1814 } ) ;
1915
20- // Define a modified version with different structure (for mismatch testing)
21- const TestCompilationFlowModified = new Flow < { value : number } > ( { slug : 'test_compilation_flow' } )
22- . step ( { slug : 'double' } , async ( input ) => {
23- await delay ( 1 ) ;
24- return input . run . value * 2 ;
25- } )
26- . step ( { slug : 'triple' , dependsOn : [ 'double' ] } , async ( input ) => {
27- await delay ( 1 ) ;
28- return input . double * 3 ;
29- } ) ;
30-
3116function createLogger ( module : string ) {
3217 return {
3318 debug : console . log . bind ( console , `[${ module } ]` ) ,
@@ -37,19 +22,15 @@ function createLogger(module: string) {
3722 } ;
3823}
3924
40- function createPlatformAdapterWithEnv (
25+ function createPlatformAdapterWithLocalEnv (
4126 sql : postgres . Sql ,
42- envOverrides : Record < string , string > = { }
27+ isLocal : boolean
4328) {
4429 const baseAdapter = createTestPlatformAdapter ( sql ) ;
45- const modifiedEnv = {
46- ...baseAdapter . env ,
47- ...envOverrides ,
48- } ;
4930
5031 return {
5132 ...baseAdapter ,
52- get env ( ) { return modifiedEnv ; } ,
33+ get isLocalEnvironment ( ) { return isLocal ; } ,
5334 } ;
5435}
5536
@@ -75,7 +56,7 @@ Deno.test(
7556 pollIntervalMs : 200 ,
7657 } ,
7758 createLogger ,
78- createPlatformAdapterWithEnv ( sql )
59+ createPlatformAdapterWithLocalEnv ( sql , false )
7960 ) ;
8061
8162 try {
@@ -132,7 +113,7 @@ Deno.test(
132113 pollIntervalMs : 200 ,
133114 } ,
134115 createLogger ,
135- createPlatformAdapterWithEnv ( sql )
116+ createPlatformAdapterWithLocalEnv ( sql , false )
136117 ) ;
137118
138119 try {
@@ -166,11 +147,8 @@ Deno.test(
166147 await sql `SELECT pgflow.add_step('test_compilation_flow', 'double')` ;
167148 await sql `SELECT pgflow.add_step('test_compilation_flow', 'different_step', deps_slugs => ARRAY['double']::text[])` ;
168149
169- // Use non-local keys to simulate production mode
170- const platformAdapter = createPlatformAdapterWithEnv ( sql , {
171- SUPABASE_ANON_KEY : 'prod-anon-key-not-local' ,
172- SUPABASE_SERVICE_ROLE_KEY : 'prod-service-key-not-local' ,
173- } ) ;
150+ // Use isLocal: false to simulate production mode
151+ const platformAdapter = createPlatformAdapterWithLocalEnv ( sql , false ) ;
174152
175153 const worker = createFlowWorker (
176154 TestCompilationFlow , // Has only 'double' step
@@ -231,11 +209,8 @@ Deno.test(
231209 await sql `SELECT pgflow.create_flow('test_compilation_flow')` ;
232210 await sql `SELECT pgflow.add_step('test_compilation_flow', 'old_step')` ;
233211
234- // Use local keys to simulate development mode
235- const platformAdapter = createPlatformAdapterWithEnv ( sql , {
236- SUPABASE_ANON_KEY : KNOWN_LOCAL_ANON_KEY ,
237- SUPABASE_SERVICE_ROLE_KEY : KNOWN_LOCAL_SERVICE_ROLE_KEY ,
238- } ) ;
212+ // Use isLocal: true to simulate development mode
213+ const platformAdapter = createPlatformAdapterWithLocalEnv ( sql , true ) ;
239214
240215 const worker = createFlowWorker (
241216 TestCompilationFlow , // Has 'double' step, not 'old_step'
0 commit comments