Skip to content

Commit 1a6e362

Browse files
Merge pull request #3727 from SwiftPackageIndex/pull-forward-test-changes
Pull forward test changes
2 parents 13f80c4 + c619bd6 commit 1a6e362

File tree

103 files changed

+360
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+360
-201
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Testing
2121
import Vapor
2222

2323

24-
@Suite struct API_PackageController_GetRoute_ModelTests {
24+
extension AllTests.API_PackageController_GetRoute_ModelTests {
2525
typealias PackageResult = PackageController.PackageResult
2626

2727
@Test func init_no_packageName() async throws {

Tests/AppTests/API+PackageController+GetRouteTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import Testing
1818

1919

20-
@Suite struct API_PackageController_GetRouteTests {
20+
extension AllTests.API_PackageController_GetRouteTests {
2121

2222
typealias PackageResult = PackageController.PackageResult
2323

Tests/AppTests/API+PackageControllerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Testing
1919
import Vapor
2020

2121

22-
@Suite struct API_PackageControllerTests {
22+
extension AllTests.API_PackageControllerTests {
2323

2424
typealias BuildDetails = (reference: Reference, platform: Build.Platform, swiftVersion: SwiftVersion, status: Build.Status)
2525

Tests/AppTests/API+PackageSchemaTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919
import Testing
2020

2121

22-
@Suite struct API_PackageSchemaTests {
22+
extension AllTests.API_PackageSchemaTests {
2323

2424
@Test func PackageSchema_init() throws {
2525
let schema = API.PackageSchema(

Tests/AppTests/API_DependencyControllerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Testing
1818
import Vapor
1919

2020

21-
@Suite struct API_DependencyControllerTests {
21+
extension AllTests.API_DependencyControllerTests {
2222

2323
@Test func query() async throws {
2424
try await withApp { app in

Tests/AppTests/AlertingTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Dependencies
1818
import Testing
1919

2020

21-
@Suite struct AlertingTests {
21+
extension AllTests.AlertingTests {
2222

2323
@Test func validatePlatformsPresent() throws {
2424
let all = Build.Platform.allCases.map {

Tests/AppTests/AllTests.swift

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import Testing
16+
import Dependencies
17+
18+
19+
@Suite(.dependency(\.date.now, .t0)) struct AllTests { }
20+
21+
22+
extension AllTests {
23+
@Suite struct AlertingTests { }
24+
@Suite struct AnalyzerTests { }
25+
@Suite struct AnalyzerVersionThrottlingTests { }
26+
@Suite struct API_DependencyControllerTests { }
27+
@Suite struct API_PackageController_GetRoute_ModelTests { }
28+
@Suite struct API_PackageController_GetRouteTests { }
29+
@Suite struct API_PackageControllerTests { }
30+
@Suite struct API_PackageSchemaTests { }
31+
@Suite struct ApiTests { }
32+
@Suite struct AppEnvironmentTests { }
33+
@Suite struct AppTests { }
34+
@Suite struct ArrayExtensionTests { }
35+
@Suite struct ArrayStringExtensionTests { }
36+
@Suite struct ArrayVersionExtensionTests { }
37+
@Suite struct AuthorControllerTests { }
38+
@Suite struct BadgeTests { }
39+
@Suite struct BlogActionsModelTests { }
40+
@Suite struct BuildIndexModelTests { }
41+
@Suite struct BuildMonitorControllerTests { }
42+
@Suite struct BuildMonitorIndexModelTests { }
43+
@Suite struct BuildResultTests { }
44+
@Suite struct BuildShowModelTests { }
45+
@Suite struct BuildTests { }
46+
@Suite struct BuildTriggerTests { }
47+
@Suite struct CustomCollectionControllerTests { }
48+
@Suite struct CustomCollectionTests { }
49+
@Suite struct DefaultStringInterpolationTests { }
50+
@Suite struct DocUploadTests { }
51+
@Suite struct DocumentationPageProcessorTests { }
52+
@Suite struct DocumentationTargetTests { }
53+
@Suite struct EmojiTests { }
54+
@Suite struct ErrorMiddlewareTests { }
55+
@Suite struct ErrorPageModelTests { }
56+
@Suite struct ErrorReportingTests { }
57+
@Suite struct FundingLinkTests { }
58+
@Suite struct GitLiveTests { }
59+
@Suite struct GitTests { }
60+
@Suite struct GithubTests { }
61+
@Suite struct GitlabBuilderTests { }
62+
@Suite struct LiveGitlabBuilderTests { }
63+
@Suite struct HomeIndexModelTests { }
64+
@Suite struct IngestionTests { }
65+
@Suite struct IntExtTests { }
66+
@Suite struct Joined3Tests { }
67+
@Suite struct JoinedQueryBuilderTests { }
68+
@Suite struct JoinedTests { }
69+
@Suite struct KeywordControllerTests { }
70+
@Suite struct LicenseTests { }
71+
@Suite struct LiveTests { }
72+
@Suite struct MaintainerInfoIndexModelTests { }
73+
@Suite struct MaintainerInfoIndexViewTests { }
74+
@Suite struct ManifestTests { }
75+
@Suite struct MastodonTests { }
76+
@Suite struct MetricsTests { }
77+
@Suite struct MiscTests { }
78+
@Suite struct PackageCollectionControllerTests { }
79+
@Suite struct PackageCollectionTests { }
80+
@Suite struct PackageContributorsTests { }
81+
@Suite struct PackageController_BuildsRoute_BuildInfoTests { }
82+
@Suite struct PackageController_BuildsRouteTests { }
83+
@Suite struct PackageController_routesTests { }
84+
@Suite struct PackageInfoTests { }
85+
@Suite struct PackageReadmeModelTests { }
86+
@Suite struct PackageReleasesModelTests { }
87+
@Suite struct PackageResultTests { }
88+
@Suite struct PackageTests { }
89+
@Suite struct PipelineTests { }
90+
@Suite struct PlausibleTests { }
91+
@Suite struct ProductTests { }
92+
@Suite struct QueryPlanTests { }
93+
@Suite struct RSSTests { }
94+
@Suite struct ReAnalyzeVersionsTests { }
95+
@Suite struct RecentViewsTests { }
96+
@Suite struct ReconcilerTests { }
97+
@Suite struct ReferenceTests { }
98+
@Suite struct RepositoryTests { }
99+
@Suite struct ResourceReloadIdentifierTests { }
100+
@Suite struct RoutesTests { }
101+
@Suite struct S3StoreExtensionTests { }
102+
@Suite struct SQLKitExtensionTests { }
103+
@Suite struct ScoreTests { }
104+
@Suite struct SearchFilterTests { }
105+
@Suite struct SearchShowModelAppTests { }
106+
@Suite struct SearchShowModelTests { }
107+
@Suite struct SearchTests { }
108+
@Suite struct ShellOutCommandExtensionTests { }
109+
@Suite struct SignificantBuildsTests { }
110+
@Suite struct SiteURLTests { }
111+
@Suite struct SitemapTests { }
112+
@Suite struct SocialTests { }
113+
@Suite struct StatsTests { }
114+
@Suite struct StringExtTests { }
115+
@Suite struct SwiftVersionTests { }
116+
@Suite struct TargetTests { }
117+
@Suite struct ValidateSPIManifestControllerTests { }
118+
@Suite struct VersionDiffTests { }
119+
@Suite struct VersionTests { }
120+
@Suite struct ViewUtilsTests { }
121+
}

Tests/AppTests/AnalyzeErrorTests.swift

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ import Testing
2121
import Vapor
2222

2323

24+
extension AllTests {
25+
@Suite struct AnalyzeErrorTests {
26+
let socialPosts = LockIsolated<[String]>([])
27+
}
28+
}
29+
30+
2431
// Test analysis error handling.
2532
//
2633
// This suite of tests ensures that errors in batch analysis do not impact processing
2734
// of later packages.
2835
//
2936
// We analyze two packages where the first package is set up to encounter
3037
// various error states and ensure the second package is successfully processed.
31-
@Suite struct AnalyzeErrorTests {
32-
33-
let badPackageID: Package.Id = .id0
34-
let goodPackageID: Package.Id = .id1
35-
36-
let capturingLogger = CapturingLogger()
37-
let socialPosts = LockIsolated<[String]>([])
38+
extension AllTests.AnalyzeErrorTests {
39+
var badPackageID: Package.Id { .id0 }
40+
var goodPackageID: Package.Id { .id1 }
3841

3942
struct SimulatedError: Error { }
4043

@@ -58,10 +61,12 @@ import Vapor
5861
}
5962

6063
@Test func analyze_refreshCheckout_failed() async throws {
61-
try await withApp(setup, defaultDependencies, logHandler: capturingLogger) { app in
64+
let capturingLogger = CapturingLogger()
65+
try await withApp(setup, defaultDependencies) { app in
6266
try await withDependencies {
6367
$0.environment.loadSPIManifest = { _ in nil }
6468
$0.fileManager.fileExists = { @Sendable _ in true }
69+
$0.logger.set(to: capturingLogger)
6570
$0.shell.run = { @Sendable cmd, path in
6671
switch cmd {
6772
case _ where cmd.description.contains("git clone https://github.com/foo/1"):
@@ -90,10 +95,12 @@ import Vapor
9095
}
9196

9297
@Test func analyze_updateRepository_invalidPackageCachePath() async throws {
93-
try await withApp(setup, defaultDependencies, logHandler: capturingLogger) { app in
98+
let capturingLogger = CapturingLogger()
99+
try await withApp(setup, defaultDependencies) { app in
94100
try await withDependencies {
95101
$0.environment.loadSPIManifest = { _ in nil }
96102
$0.fileManager.fileExists = { @Sendable _ in true }
103+
$0.logger.set(to: capturingLogger)
97104
} operation: {
98105
// setup
99106
let pkg = try await Package.find(badPackageID, on: app.db).unwrap()
@@ -118,10 +125,12 @@ import Vapor
118125
}
119126

120127
@Test func analyze_getPackageInfo_gitCheckout_error() async throws {
121-
try await withApp(setup, defaultDependencies, logHandler: capturingLogger) { app in
128+
let capturingLogger = CapturingLogger()
129+
try await withApp(setup, defaultDependencies) { app in
122130
try await withDependencies {
123131
$0.environment.loadSPIManifest = { _ in nil }
124132
$0.fileManager.fileExists = { @Sendable _ in true }
133+
$0.logger.set(to: capturingLogger)
125134
$0.shell.run = { @Sendable cmd, path in
126135
switch cmd {
127136
case .gitCheckout(branch: "main", quiet: true) where path.hasSuffix("foo-1"):
@@ -147,7 +156,8 @@ import Vapor
147156
}
148157

149158
@Test func analyze_dumpPackage_missing_manifest() async throws {
150-
try await withApp(setup, defaultDependencies, logHandler: capturingLogger) { app in
159+
let capturingLogger = CapturingLogger()
160+
try await withApp(setup, defaultDependencies) { app in
151161
try await withDependencies {
152162
$0.environment.loadSPIManifest = { _ in nil }
153163
$0.fileManager.fileExists = { @Sendable path in
@@ -156,6 +166,7 @@ import Vapor
156166
}
157167
return true
158168
}
169+
$0.logger.set(to: capturingLogger)
159170
} operation: {
160171
// MUT
161172
try await Analyze.analyze(client: app.client,
@@ -176,7 +187,7 @@ import Vapor
176187
}
177188

178189

179-
extension AnalyzeErrorTests {
190+
extension AllTests.AnalyzeErrorTests {
180191
#if compiler(>=6.1)
181192
#warning("Move this into a trait on @Test")
182193
// See https://forums.swift.org/t/converting-xctest-invoketest-to-swift-testing/77692/4 for details
@@ -193,7 +204,7 @@ extension AnalyzeErrorTests {
193204
}
194205

195206

196-
extension AnalyzeErrorTests {
207+
extension AllTests.AnalyzeErrorTests {
197208
func defaultValidation(_ app: Application) async throws {
198209
let versions = try await Version.query(on: app.db)
199210
.filter(\.$package.$id == goodPackageID)

Tests/AppTests/AnalyzerTests.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Vapor
2626
@preconcurrency import ShellOut
2727

2828

29-
@Suite struct AnalyzerTests {
29+
extension AllTests.AnalyzerTests {
3030

3131
@Test func analyze() async throws {
3232
// End-to-end test, where we mock at the shell command level (i.e. we
@@ -1441,7 +1441,7 @@ import Vapor
14411441
// Ensure `latest` remains set in case of AppError.noValidVersions
14421442
// https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/2571
14431443
let capturingLogger = CapturingLogger()
1444-
try await withApp(logHandler: capturingLogger) { app in
1444+
try await withApp { app in
14451445
try await withDependencies {
14461446
$0.date.now = .now
14471447
$0.fileManager.fileExists = { @Sendable _ in true }
@@ -1456,6 +1456,7 @@ import Vapor
14561456
1\tPerson 2
14571457
"""
14581458
}
1459+
$0.logger.set(to: capturingLogger)
14591460
$0.shell.run = { @Sendable _, _ in return "" }
14601461
} operation: {
14611462
let pkgId = UUID()

Tests/AppTests/AnalyzerVersionThrottlingTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Dependencies
2020
import Testing
2121

2222

23-
@Suite struct AnalyzerVersionThrottlingTests {
23+
extension AllTests.AnalyzerVersionThrottlingTests {
2424

2525
@Test func throttle_keep_old() async throws {
2626
// Test keeping old when within throttling window

0 commit comments

Comments
 (0)