Skip to content

Commit 87e187d

Browse files
committed
Drop sync savePackage(s) and renamed savePackage(s)Async → savePackage(s) + related changes
1 parent b708f56 commit 87e187d

37 files changed

+465
-472
lines changed

Tests/AppTests/API+PackageController+GetRoute+ModelTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
2525
func test_init_no_packageName() async throws {
2626
// Tests behaviour when we're lacking data
2727
// setup package without package name
28-
let pkg = try savePackage(on: app.db, "1".url)
28+
let pkg = try await savePackage(on: app.db, "1".url)
2929
try await Repository(package: pkg, name: "bar", owner: "foo").save(on: app.db)
3030
let version = try App.Version(package: pkg,
3131
latest: .defaultBranch,
@@ -50,7 +50,7 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
5050
}
5151

5252
func test_init_packageIdentity() async throws {
53-
let pkg = try savePackage(on: app.db, URL(string: "https://github.com/foo/swift-bar.git")!)
53+
let pkg = try await savePackage(on: app.db, URL(string: "https://github.com/foo/swift-bar.git")!)
5454
try await Repository(package: pkg, name: "bar", owner: "foo").save(on: app.db)
5555
let version = try App.Version(package: pkg, latest: .defaultBranch, packageName: nil, reference: .branch("main"))
5656
try await version.save(on: app.db)
@@ -71,7 +71,7 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
7171
}
7272

7373
func test_init_generated_documentation() async throws {
74-
let pkg = try savePackage(on: app.db, "1".url)
74+
let pkg = try await savePackage(on: app.db, "1".url)
7575
try await Repository(package: pkg, name: "bar", owner: "foo").save(on: app.db)
7676
let version = try App.Version(package: pkg, latest: .defaultBranch, packageName: nil, reference: .branch("main"))
7777
version.docArchives = [.init(name: "archive1", title: "Archive One")]
@@ -93,7 +93,7 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
9393
}
9494

9595
func test_init_external_documentation() async throws {
96-
let pkg = try savePackage(on: app.db, "1".url)
96+
let pkg = try await savePackage(on: app.db, "1".url)
9797
try await Repository(package: pkg, name: "bar", owner: "foo").save(on: app.db)
9898
let version = try App.Version(package: pkg, latest: .defaultBranch, packageName: nil, reference: .branch("main"))
9999
version.spiManifest = try .init(yml: """
@@ -454,7 +454,7 @@ class API_PackageController_GetRoute_ModelTests: SnapshotTestCase {
454454

455455
func test_languagePlatformInfo() async throws {
456456
// setup
457-
let pkg = try savePackage(on: app.db, "1")
457+
let pkg = try await savePackage(on: app.db, "1")
458458
try await Repository(package: pkg,
459459
defaultBranch: "default",
460460
name: "bar",

Tests/AppTests/API+PackageController+GetRouteTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class API_PackageController_GetRouteTests: AppTestCase {
2323

2424
func test_releaseInfo() async throws {
2525
// setup
26-
let pkg = try savePackage(on: app.db, "1")
26+
let pkg = try await savePackage(on: app.db, "1")
2727
try await Repository(package: pkg,
2828
defaultBranch: "default",
2929
name: "bar",
@@ -69,7 +69,7 @@ class API_PackageController_GetRouteTests: AppTestCase {
6969
func test_releaseInfo_exclude_non_latest() async throws {
7070
// Test to ensure that we don't include versions with `latest IS NULL`
7171
// setup
72-
let pkg = try savePackage(on: app.db, "1")
72+
let pkg = try await savePackage(on: app.db, "1")
7373
try await Repository(package: pkg,
7474
defaultBranch: "default",
7575
name: "bar",

Tests/AppTests/API+PackageControllerTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class API_PackageControllerTests: AppTestCase {
2727
Current.date = {
2828
Date.init(timeIntervalSince1970: 1608000588) // Dec 15, 2020
2929
}
30-
let pkg = try savePackage(on: app.db, "1")
30+
let pkg = try await savePackage(on: app.db, "1")
3131
try await Repository(package: pkg,
3232
commitCount: 1433,
3333
defaultBranch: "default",
@@ -65,7 +65,7 @@ class API_PackageControllerTests: AppTestCase {
6565
Current.date = {
6666
Date.init(timeIntervalSince1970: 1608000588) // Dec 15, 2020
6767
}
68-
let pkg = try savePackage(on: app.db, "1")
68+
let pkg = try await savePackage(on: app.db, "1")
6969
try await Repository(package: pkg,
7070
commitCount: 1433,
7171
defaultBranch: "default",
@@ -135,7 +135,7 @@ class API_PackageControllerTests: AppTestCase {
135135

136136
func test_ProductCount_query() async throws {
137137
// setup
138-
let pkg = try savePackage(on: app.db, "1")
138+
let pkg = try await savePackage(on: app.db, "1")
139139
try await Repository(package: pkg,
140140
defaultBranch: "main",
141141
name: "bar",
@@ -282,7 +282,7 @@ class API_PackageControllerTests: AppTestCase {
282282
func test_BuildInfo_query() async throws {
283283
// setup
284284
do {
285-
let pkg = try savePackage(on: app.db, "1".url)
285+
let pkg = try await savePackage(on: app.db, "1".url)
286286
try await Repository(package: pkg,
287287
defaultBranch: "main",
288288
name: "bar",
@@ -304,7 +304,7 @@ class API_PackageControllerTests: AppTestCase {
304304
}
305305
}
306306
do { // unrelated package and build
307-
let pkg = try savePackage(on: app.db, "2".url)
307+
let pkg = try await savePackage(on: app.db, "2".url)
308308
try await Repository(package: pkg,
309309
defaultBranch: "main",
310310
name: "bar2",
@@ -348,7 +348,7 @@ class API_PackageControllerTests: AppTestCase {
348348
func test_GetRoute_query() async throws {
349349
// ensure GetRoute.query is wired up correctly (detailed tests are elsewhere)
350350
// setup
351-
let pkg = try savePackage(on: app.db, "1")
351+
let pkg = try await savePackage(on: app.db, "1")
352352
try await Repository(package: pkg, name: "bar", owner: "foo")
353353
.save(on: app.db)
354354
try await Version(package: pkg, latest: .defaultBranch).save(on: app.db)

Tests/AppTests/API_DependencyControllerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class API_DependencyControllerTests: AppTestCase {
2121

2222
func test_query() async throws {
2323
// setup
24-
let pkg = try savePackage(on: app.db, id: .id0, "http://github.com/foo/bar")
24+
let pkg = try await savePackage(on: app.db, id: .id0, "http://github.com/foo/bar")
2525
try await Repository(package: pkg,
2626
defaultBranch: "default",
2727
name: "bar",

Tests/AppTests/AnalyzerTests.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AnalyzerTests: AppTestCase {
3333
// expected shell commands for the happy path.)
3434
// setup
3535
let urls = ["https://github.com/foo/1", "https://github.com/foo/2"]
36-
let pkgs = try savePackages(on: app.db, urls.asURLs, processingStage: .ingestion)
36+
let pkgs = try await savePackages(on: app.db, urls.asURLs, processingStage: .ingestion)
3737
try await Repository(package: pkgs[0],
3838
defaultBranch: "main",
3939
name: "1",
@@ -300,7 +300,7 @@ class AnalyzerTests: AppTestCase {
300300
// Ensure a package that fails analysis goes back to ingesting and isn't stuck in an analysis loop
301301
// setup
302302
do {
303-
let pkg = try savePackage(on: app.db, "https://github.com/foo/1", processingStage: .ingestion)
303+
let pkg = try await savePackage(on: app.db, "https://github.com/foo/1", processingStage: .ingestion)
304304
try await Repository(package: pkg, defaultBranch: "main").save(on: app.db)
305305
}
306306

@@ -337,7 +337,7 @@ class AnalyzerTests: AppTestCase {
337337
// Ensure packages record success/error status
338338
// setup
339339
let urls = ["https://github.com/foo/1", "https://github.com/foo/2"]
340-
let pkgs = try savePackages(on: app.db, urls.asURLs, processingStage: .ingestion)
340+
let pkgs = try await savePackages(on: app.db, urls.asURLs, processingStage: .ingestion)
341341
for p in pkgs {
342342
try await Repository(package: p, defaultBranch: "main").save(on: app.db)
343343
}
@@ -383,7 +383,7 @@ class AnalyzerTests: AppTestCase {
383383
// Test to ensure exceptions don't interrupt processing
384384
// setup
385385
let urls = ["https://github.com/foo/1", "https://github.com/foo/2"]
386-
let pkgs = try savePackages(on: app.db, urls.asURLs, processingStage: .ingestion)
386+
let pkgs = try await savePackages(on: app.db, urls.asURLs, processingStage: .ingestion)
387387
for p in pkgs {
388388
try await Repository(package: p, defaultBranch: "main").save(on: app.db)
389389
}
@@ -468,7 +468,7 @@ class AnalyzerTests: AppTestCase {
468468
@MainActor
469469
func test_refreshCheckout() async throws {
470470
// setup
471-
let pkg = try savePackage(on: app.db, "1".asGithubUrl.url)
471+
let pkg = try await savePackage(on: app.db, "1".asGithubUrl.url)
472472
try await Repository(package: pkg, defaultBranch: "main").save(on: app.db)
473473
Current.fileManager.fileExists = { @Sendable _ in true }
474474
let commands = QueueIsolated<[String]>([])
@@ -729,7 +729,7 @@ class AnalyzerTests: AppTestCase {
729729
}
730730
return ""
731731
}
732-
let pkg = try savePackage(on: app.db, "https://github.com/foo/1")
732+
let pkg = try await savePackage(on: app.db, "https://github.com/foo/1")
733733
try await Repository(package: pkg, name: "1", owner: "foo").save(on: app.db)
734734
let version = try Version(id: UUID(), package: pkg, reference: .tag(.init(0, 4, 2)))
735735
try await version.save(on: app.db)
@@ -829,7 +829,7 @@ class AnalyzerTests: AppTestCase {
829829

830830
func test_updatePackages() async throws {
831831
// setup
832-
let packages = try savePackages(on: app.db, ["1", "2"].asURLs)
832+
let packages = try await savePackages(on: app.db, ["1", "2"].asURLs)
833833
.map(Joined<Package, Repository>.init(model:))
834834
let results: [Result<Joined<Package, Repository>, Error>] = [
835835
// feed in one error to see it passed through
@@ -894,7 +894,7 @@ class AnalyzerTests: AppTestCase {
894894
}
895895
return ""
896896
}
897-
let pkgs = try savePackages(on: app.db, ["1", "2"].asGithubUrls.asURLs, processingStage: .ingestion)
897+
let pkgs = try await savePackages(on: app.db, ["1", "2"].asGithubUrls.asURLs, processingStage: .ingestion)
898898
for pkg in pkgs {
899899
try await Repository(package: pkg, defaultBranch: "main").save(on: app.db)
900900
}
@@ -917,7 +917,7 @@ class AnalyzerTests: AppTestCase {
917917
// Certain git commands fail when index.lock exists
918918
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/70
919919
// setup
920-
try savePackage(on: app.db, "1".asGithubUrl.url, processingStage: .ingestion)
920+
try await savePackage(on: app.db, "1".asGithubUrl.url, processingStage: .ingestion)
921921
let pkgs = try await Package.fetchCandidates(app.db, for: .analysis, limit: 10)
922922

923923
let checkoutDir = Current.fileManager.checkoutsDirectory()
@@ -951,7 +951,7 @@ class AnalyzerTests: AppTestCase {
951951
// git checkout can still fail despite git reset --hard + git clean
952952
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/498
953953
// setup
954-
try savePackage(on: app.db, "1".asGithubUrl.url, processingStage: .ingestion)
954+
try await savePackage(on: app.db, "1".asGithubUrl.url, processingStage: .ingestion)
955955
let pkgs = try await Package.fetchCandidates(app.db, for: .analysis, limit: 10)
956956

957957
let checkoutDir = Current.fileManager.checkoutsDirectory()
@@ -1107,7 +1107,7 @@ class AnalyzerTests: AppTestCase {
11071107
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/693
11081108
// setup
11091109
do {
1110-
let pkg = try savePackage(on: app.db, id: .id0, "1".asGithubUrl.url)
1110+
let pkg = try await savePackage(on: app.db, id: .id0, "1".asGithubUrl.url)
11111111
try await Repository(package: pkg, defaultBranch: "main").save(on: app.db)
11121112
}
11131113
let pkg = try await Package.fetchCandidate(app.db, id: .id0)
@@ -1456,7 +1456,7 @@ class AnalyzerTests: AppTestCase {
14561456
// Ensure we preserve dependency counts from previous default branch version
14571457
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/2873
14581458
// setup
1459-
let pkg = try await savePackageAsync(on: app.db, id: .id0, "https://github.com/foo/1".url, processingStage: .ingestion)
1459+
let pkg = try await savePackage(on: app.db, id: .id0, "https://github.com/foo/1".url, processingStage: .ingestion)
14601460
try await Repository(package: pkg,
14611461
defaultBranch: "main",
14621462
name: "1",

0 commit comments

Comments
 (0)