@@ -225,6 +225,7 @@ class AnalyzerTests: AppTestCase {
225225 $0. git. commitCount = { @Sendable _ in 12 }
226226 $0. git. firstCommitDate = { @Sendable _ in . t0 }
227227 $0. git. getTags = { @Sendable _ in [ . tag( 1 , 0 , 0 ) , . tag( 1 , 1 , 1 ) ] }
228+ $0. git. hasBranch = { @Sendable _, _ in true }
228229 $0. git. lastCommitDate = { @Sendable _ in . t2 }
229230 $0. httpClient. mastodonPost = { @Sendable _ in }
230231 } operation: {
@@ -250,7 +251,6 @@ class AnalyzerTests: AppTestCase {
250251 packageName: " foo-1 " ,
251252 reference: . tag( 1 , 0 , 0 ) ) . save ( on: app. db)
252253
253- Current . git. hasBranch = { @Sendable _, _ in true }
254254 Current . git. revisionInfo = { @Sendable ref, _ in
255255 // simulate the following scenario:
256256 // - main branch has moved from commit0 -> commit3 (timestamp t3)
@@ -318,6 +318,7 @@ class AnalyzerTests: AppTestCase {
318318 $0. fileManager. fileExists = { @Sendable _ in true }
319319 $0. git. commitCount = { @Sendable _ in 12 }
320320 $0. git. firstCommitDate = { @Sendable _ in . t0 }
321+ $0. git. hasBranch = { @Sendable _, _ in false } // simulate analysis error via branch mismatch
321322 $0. git. lastCommitDate = { @Sendable _ in . t1 }
322323 } operation: {
323324 // setup
@@ -326,7 +327,6 @@ class AnalyzerTests: AppTestCase {
326327 try await Repository ( package : pkg, defaultBranch: " main " ) . save ( on: app. db)
327328 }
328329
329- Current . git. hasBranch = { @Sendable _, _ in false } // simulate analysis error via branch mismatch
330330 Current . git. shortlog = { @Sendable _ in " " }
331331
332332 // Ensure candidate selection is as expected
@@ -364,6 +364,7 @@ class AnalyzerTests: AppTestCase {
364364 $0. git. commitCount = { @Sendable _ in 12 }
365365 $0. git. firstCommitDate = { @Sendable _ in . t0 }
366366 $0. git. getTags = { @Sendable _ in [ . tag( 1 , 0 , 0 ) ] }
367+ $0. git. hasBranch = { @Sendable _, _ in true }
367368 $0. git. lastCommitDate = { @Sendable _ in . t1 }
368369 } operation: {
369370 // setup
@@ -374,7 +375,6 @@ class AnalyzerTests: AppTestCase {
374375 }
375376 let lastUpdate = Date ( )
376377
377- Current . git. hasBranch = { @Sendable _, _ in true }
378378 Current . git. revisionInfo = { @Sendable _, _ in . init( commit: " sha " , date: . t0) }
379379 Current . git. shortlog = { @Sendable _ in
380380 """
@@ -564,9 +564,9 @@ class AnalyzerTests: AppTestCase {
564564 func test_getIncomingVersions( ) async throws {
565565 try await withDependencies {
566566 $0. git. getTags = { @Sendable _ in [ . tag( 1 , 2 , 3 ) ] }
567+ $0. git. hasBranch = { @Sendable _, _ in true }
567568 } operation: {
568569 // setup
569- Current . git. hasBranch = { @Sendable _, _ in true }
570570 Current . git. revisionInfo = { @Sendable ref, _ in . init( commit: " sha- \( ref) " , date: . t0) }
571571 do {
572572 let pkg = Package ( id: . id0, url: " 1 " . asGithubUrl. url)
@@ -584,23 +584,26 @@ class AnalyzerTests: AppTestCase {
584584 }
585585
586586 func test_getIncomingVersions_default_branch_mismatch( ) async throws {
587- // setup
588- Current . git. hasBranch = { @Sendable _, _ in false } // simulate branch mismatch
589- do {
590- let pkg = Package ( id: . id0, url: " 1 " . asGithubUrl. url)
591- try await pkg. save ( on: app. db)
592- try await Repository ( id: . id1, package : pkg, defaultBranch: " main " ) . save ( on: app. db)
593- }
594- let pkg = try await Package . fetchCandidate ( app. db, id: . id0)
587+ try await withDependencies {
588+ $0. git. hasBranch = { @Sendable _, _ in false } // simulate branch mismatch
589+ } operation: {
590+ // setup
591+ do {
592+ let pkg = Package ( id: . id0, url: " 1 " . asGithubUrl. url)
593+ try await pkg. save ( on: app. db)
594+ try await Repository ( id: . id1, package : pkg, defaultBranch: " main " ) . save ( on: app. db)
595+ }
596+ let pkg = try await Package . fetchCandidate ( app. db, id: . id0)
595597
596- // MUT
597- do {
598- _ = try await Analyze . getIncomingVersions ( client: app. client, package : pkg)
599- XCTFail ( " expected an analysisError to be thrown " )
600- } catch let AppError . analysisError( . some( pkgId) , msg) {
601- // validate
602- XCTAssertEqual ( pkgId, . id0)
603- XCTAssertEqual ( msg, " Default branch 'main' does not exist in checkout " )
598+ // MUT
599+ do {
600+ _ = try await Analyze . getIncomingVersions ( client: app. client, package : pkg)
601+ XCTFail ( " expected an analysisError to be thrown " )
602+ } catch let AppError . analysisError( . some( pkgId) , msg) {
603+ // validate
604+ XCTAssertEqual ( pkgId, . id0)
605+ XCTAssertEqual ( msg, " Default branch 'main' does not exist in checkout " )
606+ }
604607 }
605608 }
606609
@@ -624,9 +627,9 @@ class AnalyzerTests: AppTestCase {
624627 func test_diffVersions( ) async throws {
625628 try await withDependencies {
626629 $0. git. getTags = { @Sendable _ in [ . tag( 1 , 2 , 3 ) ] }
630+ $0. git. hasBranch = { @Sendable _, _ in true }
627631 } operation: {
628632 //setup
629- Current . git. hasBranch = { @Sendable _, _ in true }
630633 Current . git. revisionInfo = { @Sendable ref, _ in
631634 if ref == . branch( " main " ) { return . init( commit: " sha.main " , date: . t0) }
632635 if ref == . tag( 1 , 2 , 3 ) { return . init( commit: " sha.1.2.3 " , date: . t1) }
@@ -905,10 +908,10 @@ class AnalyzerTests: AppTestCase {
905908 $0. git. commitCount = { @Sendable _ in 12 }
906909 $0. git. firstCommitDate = { @Sendable _ in . t0 }
907910 $0. git. getTags = { @Sendable _ in [ . tag( 1 , 0 , 0 ) , . tag( 2 , 0 , 0 ) ] }
911+ $0. git. hasBranch = { @Sendable _, _ in true }
908912 $0. git. lastCommitDate = { @Sendable _ in . t1 }
909913 } operation: {
910914 // setup
911- Current . git. hasBranch = { @Sendable _, _ in true }
912915 Current . git. revisionInfo = { @Sendable _, _ in . init( commit: " sha " , date: . t0) }
913916 Current . git. shortlog = { @Sendable _ in
914917 """
@@ -1311,6 +1314,7 @@ class AnalyzerTests: AppTestCase {
13111314 $0. git. commitCount = { @Sendable _ in 2 }
13121315 $0. git. firstCommitDate = { @Sendable _ in . t0 }
13131316 $0. git. getTags = { @Sendable _ in throw TestError . unspecifiedError }
1317+ $0. git. hasBranch = { @Sendable _, _ in true }
13141318 $0. git. lastCommitDate = { @Sendable _ in . t1 }
13151319 } operation: {
13161320 let pkgId = UUID ( )
@@ -1332,7 +1336,6 @@ class AnalyzerTests: AppTestCase {
13321336 latest: . release,
13331337 packageName: " foo-1 " ,
13341338 reference: . tag( 1 , 0 , 0 ) ) . save ( on: app. db)
1335- Current . git. hasBranch = { @Sendable _, _ in true }
13361339 Current . git. shortlog = { @Sendable _ in
13371340 """
13381341 1 \t Person 1
@@ -1419,6 +1422,7 @@ class AnalyzerTests: AppTestCase {
14191422 $0. git. commitCount = { @Sendable _ in 2 }
14201423 $0. git. firstCommitDate = { @Sendable _ in . t0 }
14211424 $0. git. getTags = { @Sendable _ in [ . tag( 1 , 0 , 0 ) ] }
1425+ $0. git. hasBranch = { @Sendable _, _ in true }
14221426 $0. git. lastCommitDate = { @Sendable _ in . t1 }
14231427 } operation: {
14241428 let pkgId = UUID ( )
@@ -1440,7 +1444,6 @@ class AnalyzerTests: AppTestCase {
14401444 latest: . release,
14411445 packageName: " foo-1 " ,
14421446 reference: . tag( 1 , 0 , 0 ) ) . save ( on: app. db)
1443- Current . git. hasBranch = { @Sendable _, _ in true }
14441447 struct Error : Swift . Error { }
14451448 Current . git. shortlog = { @Sendable _ in
14461449 """
@@ -1530,6 +1533,7 @@ class AnalyzerTests: AppTestCase {
15301533 $0. git. commitCount = { @Sendable _ in 12 }
15311534 $0. git. firstCommitDate = { @Sendable _ in . t0 }
15321535 $0. git. getTags = { @Sendable _ in [ ] }
1536+ $0. git. hasBranch = { @Sendable _, _ in true }
15331537 $0. git. lastCommitDate = { @Sendable _ in . t1 }
15341538 } operation: {
15351539 // setup
@@ -1539,7 +1543,6 @@ class AnalyzerTests: AppTestCase {
15391543 name: " 1 " ,
15401544 owner: " foo " ,
15411545 stars: 100 ) . save ( on: app. db)
1542- Current . git. hasBranch = { @Sendable _, _ in true }
15431546 Current . git. revisionInfo = { @Sendable _, _ in . init( commit: " sha1 " , date: . t0) }
15441547 Current . git. shortlog = { @Sendable _ in " 10 \t Person 1 " }
15451548 Current . shell. run = { @Sendable cmd, path in
0 commit comments