@@ -22,7 +22,7 @@ import S3Store
2222import Vapor
2323
2424
25- class IngestorTests : AppTestCase {
25+ class IngestionTests : AppTestCase {
2626
2727 func test_ingest_basic( ) async throws {
2828 // setup
@@ -38,7 +38,7 @@ class IngestorTests: AppTestCase {
3838 $0. date. now = . now
3939 } operation: {
4040 // MUT
41- try await ingest ( client: app. client, database: app. db, mode: . limit( 10 ) )
41+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 10 ) )
4242 }
4343
4444 // validate
@@ -77,7 +77,7 @@ class IngestorTests: AppTestCase {
7777 Current . fetchLicense = { _, _, _ in Github . License ( htmlUrl: " license " ) }
7878
7979 // MUT
80- await ingest ( client: app. client, database: app. db, packages: packages)
80+ await Ingestion . ingest ( client: app. client, database: app. db, packages: packages)
8181
8282 do {
8383 // validate the second package's license is updated
@@ -97,12 +97,12 @@ class IngestorTests: AppTestCase {
9797 let repo = Repository ( packageId: try pkg. requireID ( ) )
9898
9999 // MUT
100- try await updateRepository ( on: app. db,
101- for: repo,
102- metadata: . mock( owner: " foo " , repository: " bar " ) ,
103- licenseInfo: . init( htmlUrl: " " ) ,
104- readmeInfo: . init( html: " " , htmlUrl: " " , imagesToCache: [ ] ) ,
105- s3Readme: nil )
100+ try await Ingestion . updateRepository ( on: app. db,
101+ for: repo,
102+ metadata: . mock( owner: " foo " , repository: " bar " ) ,
103+ licenseInfo: . init( htmlUrl: " " ) ,
104+ readmeInfo: . init( html: " " , htmlUrl: " " , imagesToCache: [ ] ) ,
105+ s3Readme: nil )
106106
107107 // validate
108108 do {
@@ -154,16 +154,16 @@ class IngestorTests: AppTestCase {
154154 summary: " package desc " )
155155
156156 // MUT
157- try await updateRepository ( on: app. db,
158- for: repo,
159- metadata: md,
160- licenseInfo: . init( htmlUrl: " license url " ) ,
161- readmeInfo: . init( etag: " etag " ,
162- html: " readme html https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com " ,
163- htmlUrl: " readme html url " ,
164- imagesToCache: [ ] ) ,
165- s3Readme: . cached( s3ObjectUrl: " url " , githubEtag: " etag " ) ,
166- fork: . parentURL( " https://github.com/foo/bar.git " ) )
157+ try await Ingestion . updateRepository ( on: app. db,
158+ for: repo,
159+ metadata: md,
160+ licenseInfo: . init( htmlUrl: " license url " ) ,
161+ readmeInfo: . init( etag: " etag " ,
162+ html: " readme html https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com " ,
163+ htmlUrl: " readme html url " ,
164+ imagesToCache: [ ] ) ,
165+ s3Readme: . cached( s3ObjectUrl: " url " , githubEtag: " etag " ) ,
166+ fork: . parentURL( " https://github.com/foo/bar.git " ) )
167167
168168 // validate
169169 do {
@@ -229,14 +229,14 @@ class IngestorTests: AppTestCase {
229229 summary: " package desc " )
230230
231231 // MUT
232- try await updateRepository ( on: app. db,
233- for: repo,
234- metadata: md,
235- licenseInfo: . init( htmlUrl: " license url " ) ,
236- readmeInfo: . init( html: " readme html " ,
237- htmlUrl: " readme html url " ,
238- imagesToCache: [ ] ) ,
239- s3Readme: nil )
232+ try await Ingestion . updateRepository ( on: app. db,
233+ for: repo,
234+ metadata: md,
235+ licenseInfo: . init( htmlUrl: " license url " ) ,
236+ readmeInfo: . init( html: " readme html " ,
237+ htmlUrl: " readme html url " ,
238+ imagesToCache: [ ] ) ,
239+ s3Readme: nil )
240240
241241 // validate
242242 do {
@@ -310,7 +310,7 @@ class IngestorTests: AppTestCase {
310310 $0. date. now = . now
311311 } operation: {
312312 // MUT
313- try await ingest ( client: app. client, database: app. db, mode: . limit( testUrls. count) )
313+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( testUrls. count) )
314314 }
315315
316316 // validate
@@ -337,7 +337,7 @@ class IngestorTests: AppTestCase {
337337 $0. date. now = . now
338338 } operation: {
339339 // MUT
340- try await ingest ( client: app. client, database: app. db, mode: . limit( 10 ) )
340+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 10 ) )
341341 }
342342
343343 // validate
@@ -389,7 +389,7 @@ class IngestorTests: AppTestCase {
389389 $0. date. now = . now
390390 } operation: {
391391 // MUT
392- try await ingest ( client: app. client, database: app. db, mode: . limit( 10 ) )
392+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 10 ) )
393393 }
394394
395395 // validate repositories (single element pointing to the ingested package)
@@ -490,7 +490,7 @@ class IngestorTests: AppTestCase {
490490
491491 do { // first ingestion, no readme has been saved
492492 // MUT
493- try await ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
493+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
494494
495495 // validate
496496 try await XCTAssertEqualAsync ( await Repository . query ( on: app. db) . count ( ) , 1 )
@@ -506,7 +506,7 @@ class IngestorTests: AppTestCase {
506506 try await pkg. save ( on: app. db)
507507
508508 // MUT
509- try await ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
509+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
510510
511511 // validate
512512 try await XCTAssertEqualAsync ( await Repository . query ( on: app. db) . count ( ) , 1 )
@@ -522,7 +522,7 @@ class IngestorTests: AppTestCase {
522522 try await pkg. save ( on: app. db)
523523
524524 // MUT
525- try await ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
525+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
526526
527527 // validate
528528 try await XCTAssertEqualAsync ( await Repository . query ( on: app. db) . count ( ) , 1 )
@@ -573,7 +573,7 @@ class IngestorTests: AppTestCase {
573573 $0. date. now = . now
574574 } operation: {
575575 // MUT
576- try await ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
576+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
577577 }
578578
579579 // There should only be one call as `storeS3ReadmeImages` takes the array of images.
@@ -604,7 +604,7 @@ class IngestorTests: AppTestCase {
604604 } operation: {
605605 // MUT
606606 let app = self . app!
607- try await ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
607+ try await Ingestion . ingest ( client: app. client, database: app. db, mode: . limit( 1 ) )
608608 }
609609
610610 // validate
@@ -660,23 +660,23 @@ class IngestorTests: AppTestCase {
660660 try await Package ( url: " https://github.com/bar/forked.git " , processingStage: . analysis) . save ( on: app. db)
661661
662662 // test lookup when package is in the index
663- let fork = await getFork ( on: app. db, parent: . init( url: " https://github.com/foo/parent.git " ) )
663+ let fork = await Ingestion . getFork ( on: app. db, parent: . init( url: " https://github.com/foo/parent.git " ) )
664664 XCTAssertEqual ( fork, . parentId( id: . id0, fallbackURL: " https://github.com/foo/parent.git " ) )
665665
666666 // test lookup when package is in the index but with different case in URL
667- let fork2 = await getFork ( on: app. db, parent: . init( url: " https://github.com/Foo/Parent.git " ) )
667+ let fork2 = await Ingestion . getFork ( on: app. db, parent: . init( url: " https://github.com/Foo/Parent.git " ) )
668668 XCTAssertEqual ( fork2, . parentId( id: . id0, fallbackURL: " https://github.com/Foo/Parent.git " ) )
669669
670670 // test whem metadata repo url doesn't have `.git` at end
671- let fork3 = await getFork ( on: app. db, parent: . init( url: " https://github.com/Foo/Parent " ) )
671+ let fork3 = await Ingestion . getFork ( on: app. db, parent: . init( url: " https://github.com/Foo/Parent " ) )
672672 XCTAssertEqual ( fork3, . parentId( id: . id0, fallbackURL: " https://github.com/Foo/Parent.git " ) )
673673
674674 // test lookup when package is not in the index
675- let fork4 = await getFork ( on: app. db, parent: . init( url: " https://github.com/some/other.git " ) )
675+ let fork4 = await Ingestion . getFork ( on: app. db, parent: . init( url: " https://github.com/some/other.git " ) )
676676 XCTAssertEqual ( fork4, . parentURL( " https://github.com/some/other.git " ) )
677677
678678 // test lookup when parent url is nil
679- let fork5 = await getFork ( on: app. db, parent: nil )
679+ let fork5 = await Ingestion . getFork ( on: app. db, parent: nil )
680680 XCTAssertEqual ( fork5, nil )
681681 }
682682}
0 commit comments