@@ -113,13 +113,23 @@ describe('flattenReusedIngestArtifactBundle', () => {
113113 expect ( readReusedIngestMetadata ( root ) ?. sourceRunId ) . toBe ( '25763435778' ) ;
114114 } ) ;
115115
116- it ( 'rejects flattening when it would overwrite an existing artifact' , ( ) => {
116+ it ( 'keeps the run-local artifact when a reused artifact collides ' , ( ) => {
117117 const root = tempDir ( ) ;
118118 fs . mkdirSync ( path . join ( root , 'results_bmk' ) ) ;
119+ fs . writeFileSync ( path . join ( root , 'results_bmk' , 'fresh.json' ) , '[]' ) ;
119120 fs . mkdirSync ( path . join ( root , 'reused-ingest-artifacts' , 'results_bmk' ) , {
120121 recursive : true ,
121122 } ) ;
123+ fs . writeFileSync (
124+ path . join ( root , 'reused-ingest-artifacts' , 'results_bmk' , 'reused.json' ) ,
125+ '[]' ,
126+ ) ;
127+ fs . mkdirSync ( path . join ( root , 'reused-ingest-artifacts' , 'run-stats' ) , { recursive : true } ) ;
122128
123- expect ( ( ) => flattenReusedIngestArtifactBundle ( root ) ) . toThrow ( / d e s t i n a t i o n a l r e a d y e x i s t s / u) ;
129+ expect ( flattenReusedIngestArtifactBundle ( root ) ) . toEqual ( [ 'run-stats' ] ) ;
130+ expect ( fs . existsSync ( path . join ( root , 'reused-ingest-artifacts' ) ) ) . toBe ( false ) ;
131+ expect ( fs . existsSync ( path . join ( root , 'run-stats' ) ) ) . toBe ( true ) ;
132+ expect ( fs . existsSync ( path . join ( root , 'results_bmk' , 'fresh.json' ) ) ) . toBe ( true ) ;
133+ expect ( fs . existsSync ( path . join ( root , 'results_bmk' , 'reused.json' ) ) ) . toBe ( false ) ;
124134 } ) ;
125135} ) ;
0 commit comments