Skip to content

Commit 9564837

Browse files
committed
Drop client parameter from fetchLicense
1 parent 3a4aa78 commit 9564837

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

Sources/App/Commands/Ingestion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ enum Ingestion {
264264
}
265265

266266
async let metadata = try await Current.fetchMetadata(client, owner, repository)
267-
async let license = await github.fetchLicense(client, owner, repository)
267+
async let license = await github.fetchLicense(owner, repository)
268268
async let readme = await Current.fetchReadme(client, owner, repository)
269269

270270
do {

Sources/App/Core/Dependencies/GithubClient.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@
1515

1616
import Dependencies
1717
import DependenciesMacros
18-
#warning("temporary, until we drop Client")
19-
import protocol Vapor.Client
2018

2119

2220
@DependencyClient
2321
struct GithubClient {
24-
#warning("drop Client parameter")
25-
var fetchLicense: @Sendable (_ client: Client, _ owner: String, _ repository: String) async -> Github.License?
22+
var fetchLicense: @Sendable (_ owner: String, _ repository: String) async -> Github.License?
2623
}
2724

2825

2926
extension GithubClient: DependencyKey {
3027
static var liveValue: Self {
3128
.init(
32-
fetchLicense: { client, owner, repo in await Github.fetchLicense(client:client, owner: owner, repository: repo) }
29+
fetchLicense: { owner, repo in await Github.fetchLicense(owner: owner, repository: repo) }
3330
)
3431
}
3532
}

Tests/AppTests/IngestionTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class IngestionTests: AppTestCase {
3636

3737
try await withDependencies {
3838
$0.date.now = .now
39-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
39+
$0.github.fetchLicense = { @Sendable _, _ in nil }
4040
} operation: {
4141
// MUT
4242
try await Ingestion.ingest(client: app.client, database: app.db, mode: .limit(10))
@@ -66,7 +66,7 @@ class IngestionTests: AppTestCase {
6666
func test_ingest_continue_on_error() async throws {
6767
// Test completion of ingestion despite early error
6868
try await withDependencies {
69-
$0.github.fetchLicense = { @Sendable _, _, _ in Github.License(htmlUrl: "license") }
69+
$0.github.fetchLicense = { @Sendable _, _ in Github.License(htmlUrl: "license") }
7070
} operation: {
7171
// setup
7272
let packages = try await savePackages(on: app.db, ["https://github.com/foo/1",
@@ -312,7 +312,7 @@ class IngestionTests: AppTestCase {
312312

313313
try await withDependencies {
314314
$0.date.now = .now
315-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
315+
$0.github.fetchLicense = { @Sendable _, _ in nil }
316316
} operation: {
317317
// MUT
318318
try await Ingestion.ingest(client: app.client, database: app.db, mode: .limit(testUrls.count))
@@ -340,7 +340,7 @@ class IngestionTests: AppTestCase {
340340

341341
try await withDependencies {
342342
$0.date.now = .now
343-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
343+
$0.github.fetchLicense = { @Sendable _, _ in nil }
344344
} operation: {
345345
// MUT
346346
try await Ingestion.ingest(client: app.client, database: app.db, mode: .limit(10))
@@ -393,7 +393,7 @@ class IngestionTests: AppTestCase {
393393

394394
try await withDependencies {
395395
$0.date.now = .now
396-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
396+
$0.github.fetchLicense = { @Sendable _, _ in nil }
397397
} operation: {
398398
// MUT
399399
try await Ingestion.ingest(client: app.client, database: app.db, mode: .limit(10))
@@ -461,7 +461,7 @@ class IngestionTests: AppTestCase {
461461
func test_ingest_storeS3Readme() async throws {
462462
try await withDependencies {
463463
$0.date.now = .now
464-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
464+
$0.github.fetchLicense = { @Sendable _, _ in nil }
465465
} operation: {
466466
// setup
467467
let app = self.app!
@@ -579,7 +579,7 @@ class IngestionTests: AppTestCase {
579579

580580
try await withDependencies {
581581
$0.date.now = .now
582-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
582+
$0.github.fetchLicense = { @Sendable _, _ in nil }
583583
} operation: {
584584
// MUT
585585
try await Ingestion.ingest(client: app.client, database: app.db, mode: .limit(1))
@@ -610,7 +610,7 @@ class IngestionTests: AppTestCase {
610610
do { // first ingestion, no readme has been saved
611611
try await withDependencies {
612612
$0.date.now = .now
613-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
613+
$0.github.fetchLicense = { @Sendable _, _ in nil }
614614
} operation: {
615615
// MUT
616616
let app = self.app!
@@ -631,7 +631,7 @@ class IngestionTests: AppTestCase {
631631
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/761
632632
try await withDependencies {
633633
// use live fetch request for fetchLicense, whose behaviour we want to test ...
634-
$0.github.fetchLicense = { @Sendable client, owner, repo in await Github.fetchLicense(client: client, owner: owner, repository: repo) }
634+
$0.github.fetchLicense = { @Sendable owner, repo in await Github.fetchLicense(owner: owner, repository: repo) }
635635
} operation: {
636636
// setup
637637
let pkg = Package(url: "https://github.com/foo/1")

Tests/AppTests/MastodonTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class MastodonTests: AppTestCase {
2525
let message = QueueIsolated<String?>(nil)
2626
try await withDependencies {
2727
$0.environment.allowSocialPosts = { true }
28-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
28+
$0.github.fetchLicense = { @Sendable _, _ in nil }
2929
$0.httpClient.mastodonPost = { @Sendable msg in
3030
if message.value == nil {
3131
message.setValue(msg)

Tests/AppTests/PackageTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ final class PackageTests: AppTestCase {
311311
let url = "1".asGithubUrl
312312
try await withDependencies {
313313
$0.date.now = .now
314-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
314+
$0.github.fetchLicense = { @Sendable _, _ in nil }
315315
$0.packageListRepository.fetchPackageList = { @Sendable _ in [url.url] }
316316
$0.packageListRepository.fetchPackageDenyList = { @Sendable _ in [] }
317317
$0.packageListRepository.fetchCustomCollections = { @Sendable _ in [] }

Tests/AppTests/PipelineTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class PipelineTests: AppTestCase {
161161
let urls = ["1", "2", "3"].asGithubUrls
162162
try await withDependencies {
163163
$0.date.now = .now
164-
$0.github.fetchLicense = { @Sendable _, _, _ in nil }
164+
$0.github.fetchLicense = { @Sendable _, _ in nil }
165165
$0.packageListRepository.fetchPackageList = { @Sendable _ in urls.asURLs }
166166
$0.packageListRepository.fetchPackageDenyList = { @Sendable _ in [] }
167167
$0.packageListRepository.fetchCustomCollections = { @Sendable _ in [] }

0 commit comments

Comments
 (0)