@@ -466,6 +466,7 @@ class IngestionTests: AppTestCase {
466466
467467 func test_ingest_storeS3Readme( ) async throws {
468468 let fetchCalls = QueueIsolated ( 0 )
469+ let storeCalls = QueueIsolated ( 0 )
469470 try await withDependencies {
470471 $0. date. now = . now
471472 $0. github. fetchLicense = { @Sendable _, _ in nil }
@@ -484,13 +485,7 @@ class IngestionTests: AppTestCase {
484485 imagesToCache: [ ] )
485486 }
486487 }
487- } operation: {
488- // setup
489- let app = self . app!
490- let pkg = Package ( url: " https://github.com/foo/bar " . url, processingStage: . reconciliation)
491- try await pkg. save ( on: app. db)
492- let storeCalls = QueueIsolated ( 0 )
493- Current . storeS3Readme = { owner, repo, html in
488+ $0. s3. storeReadme = { owner, repo, html in
494489 storeCalls. increment ( )
495490 XCTAssertEqual ( owner, " foo " )
496491 XCTAssertEqual ( repo, " bar " )
@@ -501,6 +496,11 @@ class IngestionTests: AppTestCase {
501496 }
502497 return " objectUrl "
503498 }
499+ } operation: {
500+ // setup
501+ let app = self . app!
502+ let pkg = Package ( url: " https://github.com/foo/bar " . url, processingStage: . reconciliation)
503+ try await pkg. save ( on: app. db)
504504
505505 do { // first ingestion, no readme has been saved
506506 // MUT
@@ -553,13 +553,7 @@ class IngestionTests: AppTestCase {
553553 let pkg = Package ( url: " https://github.com/foo/bar " . url,
554554 processingStage: . reconciliation)
555555 try await pkg. save ( on: app. db)
556- Current . storeS3Readme = { _, _, _ in " objectUrl " }
557556 let storeS3ReadmeImagesCalls = QueueIsolated ( 0 )
558- Current . storeS3ReadmeImages = { _, imagesToCache in
559- storeS3ReadmeImagesCalls. increment ( )
560-
561- XCTAssertEqual ( imagesToCache. count, 2 )
562- }
563557
564558 try await withDependencies {
565559 $0. date. now = . now
@@ -586,6 +580,11 @@ class IngestionTests: AppTestCase {
586580 path: " /foo/bar/with-jwt-2.jpg " ) )
587581 ] )
588582 }
583+ $0. s3. storeReadme = { _, _, _ in " objectUrl " }
584+ $0. s3. storeReadmeImages = { imagesToCache in
585+ storeS3ReadmeImagesCalls. increment ( )
586+ XCTAssertEqual ( imagesToCache. count, 2 )
587+ }
589588 } operation: {
590589 // MUT
591590 try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
@@ -601,10 +600,6 @@ class IngestionTests: AppTestCase {
601600 let pkg = Package ( url: " https://github.com/foo/bar " . url, processingStage: . reconciliation)
602601 try await pkg. save ( on: app. db)
603602 let storeCalls = QueueIsolated ( 0 )
604- Current . storeS3Readme = { owner, repo, html throws ( S3Readme . Error) in
605- storeCalls. increment ( )
606- throw . storeReadmeFailed
607- }
608603
609604 do { // first ingestion, no readme has been saved
610605 try await withDependencies {
@@ -617,6 +612,10 @@ class IngestionTests: AppTestCase {
617612 htmlUrl: " readme url " ,
618613 imagesToCache: [ ] )
619614 }
615+ $0. s3. storeReadme = { owner, repo, html throws ( S3Readme . Error) in
616+ storeCalls. increment ( )
617+ throw . storeReadmeFailed
618+ }
620619 } operation: {
621620 // MUT
622621 let app = self . app!
0 commit comments