From 918dc8d1a2324d28389dc2bd074ac653306f1220 Mon Sep 17 00:00:00 2001 From: Dave Verwer Date: Mon, 13 Nov 2023 14:14:07 +0000 Subject: [PATCH] Tested ingestion with `fetchFunding`. --- Tests/AppTests/IngestorTests.swift | 16 ++++++++++++++++ Tests/AppTests/Mocks/GithubMetadata+mock.swift | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/Tests/AppTests/IngestorTests.swift b/Tests/AppTests/IngestorTests.swift index 4abbef68ce..c135bb577c 100644 --- a/Tests/AppTests/IngestorTests.swift +++ b/Tests/AppTests/IngestorTests.swift @@ -491,6 +491,22 @@ class IngestorTests: AppTestCase { } } + func test_ingest_storeFunding() async throws { + // Setup + let pkg = Package(url: "https://github.com/foo/bar".url, processingStage: .reconciliation) + try await pkg.save(on: app.db) + + Current.fetchFunding = { _, _ in .mock } + + // MUT + try await ingest(client: app.client, database: app.db, logger: app.logger, mode: .limit(1)) + + // Validation + try await XCTAssertEqualAsync(await Repository.query(on: app.db).count(), 1) + let repo = try await XCTUnwrapAsync(await Repository.query(on: app.db).first()) + XCTAssertEqual(repo.funding, .init(customUrls: ["example.com/funding/link"], github: ["GitHubUsername"])) + } + func test_issue_761_no_license() async throws { // https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/761 // setup diff --git a/Tests/AppTests/Mocks/GithubMetadata+mock.swift b/Tests/AppTests/Mocks/GithubMetadata+mock.swift index 1fefbf359e..6a815d6774 100644 --- a/Tests/AppTests/Mocks/GithubMetadata+mock.swift +++ b/Tests/AppTests/Mocks/GithubMetadata+mock.swift @@ -98,3 +98,7 @@ extension Github.Metadata { ) } } + +extension Github.Funding { + static let mock: Self = .init(customUrls: ["example.com/funding/link"], github: ["GitHubUsername"]) +}