1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- import XCTest
16-
1715@testable import App
1816
1917import Dependencies
18+ import Testing
2019
2120
22- class PackageContributorsTests : AppTestCase {
21+ @ Suite struct PackageContributorsTests {
2322
24- func test_packageAuthors_hasAuthors ( ) throws {
23+ @ Test func packageAuthors_hasAuthors ( ) throws {
2524 let noPackageAuthors = PackageAuthors ( authors: [ ] , numberOfContributors: 0 )
2625
2726 let somePackageAuthors = PackageAuthors ( authors: [
2827 . init( name: " Person One " ) ,
2928 . init( name: " Person Two " )
3029 ] , numberOfContributors: 0 )
3130
32- XCTAssertFalse ( noPackageAuthors. hasAuthors)
33- XCTAssertTrue ( somePackageAuthors. hasAuthors)
31+ #expect ( ! noPackageAuthors. hasAuthors)
32+ #expect ( somePackageAuthors. hasAuthors)
3433 }
3534
36- func test_CommitSelector_primaryContributors ( ) throws {
35+ @ Test func CommitSelector_primaryContributors ( ) throws {
3736
3837 let candidates = [ PackageContributors . Contributor ( numberOfCommits: 10 , name: " Tim " ) ,
3938 PackageContributors . Contributor ( numberOfCommits: 100 , name: " John " ) ,
@@ -43,30 +42,30 @@ class PackageContributorsTests : AppTestCase {
4342 // MUT
4443 let authors = PackageContributors . primaryContributors ( candidates: candidates, threshold: 0.6 )
4544
46- XCTAssertEqual ( authors. count, 2 )
47- XCTAssertEqual ( authors. map ( \. name) , [ " Maria " , " Nathalie " ] )
45+ #expect ( authors. count == 2 )
46+ #expect ( authors. map ( \. name) == [ " Maria " , " Nathalie " ] )
4847
4948 }
5049
51-
52- func test_CommitSelector_primaryContributors_noCandidates( ) throws {
50+ @Test func CommitSelector_primaryContributors_noCandidates( ) throws {
5351 // MUT
5452 let authors = PackageContributors . primaryContributors ( candidates: [ ] , threshold: 0.6 )
5553
56- XCTAssertEqual ( authors. count, 0 )
54+ #expect ( authors. count == 0 )
5755 }
5856
59- func test_CommitSelector_filter_singleCandidate ( ) throws {
57+ @ Test func CommitSelector_filter_singleCandidate ( ) throws {
6058 // MUT
61- let authors = PackageContributors . primaryContributors ( candidates: [ PackageContributors . Contributor ( numberOfCommits: 10 , name: " Tim " ) ] ,
62- threshold: 0.6 )
59+ let authors = PackageContributors
60+ . primaryContributors ( candidates: [ PackageContributors . Contributor ( numberOfCommits: 10 ,
61+ name: " Tim " ) ] ,
62+ threshold: 0.6 )
6363
64- XCTAssertEqual ( authors. count, 1 )
65- XCTAssertEqual ( authors. map ( \. name) , [ " Tim " ] )
64+ #expect ( authors. count == 1 )
65+ #expect ( authors. map ( \. name) == [ " Tim " ] )
6666 }
6767
68-
69- func test_PackageContributors_extract( ) async throws {
68+ @Test func PackageContributors_extract( ) async throws {
7069 try await withDependencies {
7170 $0. fileManager. fileExists = { @Sendable _ in true }
7271 $0. git. shortlog = { @Sendable _ in
@@ -85,19 +84,21 @@ class PackageContributorsTests : AppTestCase {
8584 """
8685 }
8786 } operation: {
88- // setup
89- let pkg = try await savePackage ( on: app. db, " 1 " . asGithubUrl. url)
90-
91- // MUT
92- let pkgAuthors = try await PackageContributors . extract ( gitCacheDirectoryPath: " " ,
93- packageID: pkg. id)
94-
95- XCTAssertEqual ( pkgAuthors. authors, [ Author ( name: " Person 1 " ) ,
96- Author ( name: " Person 2 " ) ,
97- Author ( name: " Person 3 " ) ,
98- Author ( name: " Person 4 " ) ,
99- Author ( name: " Person 5 " ) ] )
100- XCTAssertEqual ( pkgAuthors. numberOfContributors, 6 )
87+ try await withApp { app in
88+ // setup
89+ let pkg = try await savePackage ( on: app. db, " 1 " . asGithubUrl. url)
90+
91+ // MUT
92+ let pkgAuthors = try await PackageContributors . extract ( gitCacheDirectoryPath: " " ,
93+ packageID: pkg. id)
94+
95+ #expect( pkgAuthors. authors == [ Author ( name: " Person 1 " ) ,
96+ Author ( name: " Person 2 " ) ,
97+ Author ( name: " Person 3 " ) ,
98+ Author ( name: " Person 4 " ) ,
99+ Author ( name: " Person 5 " ) ] )
100+ #expect( pkgAuthors. numberOfContributors == 6 )
101+ }
101102 }
102103 }
103104
0 commit comments