@@ -65,6 +65,11 @@ import {
6565} from '../../src/db/index.js' ;
6666import { PipelineContext } from '../../src/domain/graph/builder/context.js' ;
6767import { reopenNativeDb } from '../../src/domain/graph/builder/stages/native-db-lifecycle.js' ;
68+ import {
69+ openNativeDatabase ,
70+ runPostNativeAnalysis ,
71+ } from '../../src/domain/graph/builder/stages/native-orchestrator.js' ;
72+ import { openNativeDbForFanMetrics } from '../../src/features/branch-compare.js' ;
6873
6974let tmpDir : string ;
7075let dbPath : string ;
@@ -119,3 +124,49 @@ describe('reopenNativeDb (build pipeline) threads ctx.config.db.busyTimeoutMs in
119124 expect ( openReadWriteCalls [ 0 ] ?. [ 1 ] ) . toBe ( CUSTOM_BUSY_TIMEOUT_MS ) ;
120125 } ) ;
121126} ) ;
127+
128+ describe ( 'openNativeDatabase (build pipeline) threads ctx.config.db.busyTimeoutMs into NativeDatabase.openReadWrite' , ( ) => {
129+ it ( 'passes ctx.config.db.busyTimeoutMs to the native factory' , ( ) => {
130+ openReadWriteCalls . length = 0 ;
131+ const ctx = new PipelineContext ( ) ;
132+ ctx . dbPath = dbPath ;
133+ ctx . db = { close : ( ) => { } } as PipelineContext [ 'db' ] ;
134+ ctx . nativeAvailable = true ;
135+ ctx . config = { db : { busyTimeoutMs : CUSTOM_BUSY_TIMEOUT_MS } } as PipelineContext [ 'config' ] ;
136+
137+ openNativeDatabase ( ctx ) ;
138+
139+ expect ( openReadWriteCalls ) . toHaveLength ( 1 ) ;
140+ expect ( openReadWriteCalls [ 0 ] ?. [ 1 ] ) . toBe ( CUSTOM_BUSY_TIMEOUT_MS ) ;
141+ } ) ;
142+ } ) ;
143+
144+ describe ( 'runPostNativeAnalysis (build pipeline) threads ctx.config.db.busyTimeoutMs into NativeDatabase.openReadWrite' , ( ) => {
145+ it ( 'passes ctx.config.db.busyTimeoutMs to the native factory' , async ( ) => {
146+ openReadWriteCalls . length = 0 ;
147+ const ctx = new PipelineContext ( ) ;
148+ ctx . dbPath = dbPath ;
149+ ctx . db = openDb ( dbPath ) ;
150+ ctx . rootDir = tmpDir ;
151+ ctx . opts = { engine : 'native' } ;
152+ ctx . config = { db : { busyTimeoutMs : CUSTOM_BUSY_TIMEOUT_MS } } as PipelineContext [ 'config' ] ;
153+
154+ try {
155+ await runPostNativeAnalysis ( ctx , new Map ( ) , [ ] ) ;
156+ } finally {
157+ closeDb ( ctx . db as Parameters < typeof closeDb > [ 0 ] ) ;
158+ }
159+
160+ expect ( openReadWriteCalls ) . toHaveLength ( 1 ) ;
161+ expect ( openReadWriteCalls [ 0 ] ?. [ 1 ] ) . toBe ( CUSTOM_BUSY_TIMEOUT_MS ) ;
162+ } ) ;
163+ } ) ;
164+
165+ describe ( 'openNativeDbForFanMetrics (branch-compare) threads the configured busyTimeoutMs into NativeDatabase.openReadonly' , ( ) => {
166+ it ( 'passes the configured busyTimeoutMs to the native factory' , ( ) => {
167+ openReadonlyCalls . length = 0 ;
168+ openNativeDbForFanMetrics ( dbPath ) ;
169+ expect ( openReadonlyCalls ) . toHaveLength ( 1 ) ;
170+ expect ( openReadonlyCalls [ 0 ] ?. [ 1 ] ) . toBe ( CUSTOM_BUSY_TIMEOUT_MS ) ;
171+ } ) ;
172+ } ) ;
0 commit comments