diff --git a/Tests/AppTests/API+PackageController+GetRoute+ModelTests.swift b/Tests/AppTests/API+PackageController+GetRoute+ModelTests.swift index fdc1a5c3a..feed830b2 100644 --- a/Tests/AppTests/API+PackageController+GetRoute+ModelTests.swift +++ b/Tests/AppTests/API+PackageController+GetRoute+ModelTests.swift @@ -21,7 +21,7 @@ import Testing import Vapor -@Suite struct API_PackageController_GetRoute_ModelTests { +extension AllTests.API_PackageController_GetRoute_ModelTests { typealias PackageResult = PackageController.PackageResult @Test func init_no_packageName() async throws { diff --git a/Tests/AppTests/API+PackageController+GetRouteTests.swift b/Tests/AppTests/API+PackageController+GetRouteTests.swift index 7e04e1d36..132f8ad52 100644 --- a/Tests/AppTests/API+PackageController+GetRouteTests.swift +++ b/Tests/AppTests/API+PackageController+GetRouteTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct API_PackageController_GetRouteTests { +extension AllTests.API_PackageController_GetRouteTests { typealias PackageResult = PackageController.PackageResult diff --git a/Tests/AppTests/API+PackageControllerTests.swift b/Tests/AppTests/API+PackageControllerTests.swift index b424d0452..0f99181c0 100644 --- a/Tests/AppTests/API+PackageControllerTests.swift +++ b/Tests/AppTests/API+PackageControllerTests.swift @@ -19,7 +19,7 @@ import Testing import Vapor -@Suite struct API_PackageControllerTests { +extension AllTests.API_PackageControllerTests { typealias BuildDetails = (reference: Reference, platform: Build.Platform, swiftVersion: SwiftVersion, status: Build.Status) diff --git a/Tests/AppTests/API+PackageSchemaTests.swift b/Tests/AppTests/API+PackageSchemaTests.swift index 549e303f4..ba37bdbd7 100644 --- a/Tests/AppTests/API+PackageSchemaTests.swift +++ b/Tests/AppTests/API+PackageSchemaTests.swift @@ -19,7 +19,7 @@ import Foundation import Testing -@Suite struct API_PackageSchemaTests { +extension AllTests.API_PackageSchemaTests { @Test func PackageSchema_init() throws { let schema = API.PackageSchema( diff --git a/Tests/AppTests/API_DependencyControllerTests.swift b/Tests/AppTests/API_DependencyControllerTests.swift index 311d6f344..97ee8a92e 100644 --- a/Tests/AppTests/API_DependencyControllerTests.swift +++ b/Tests/AppTests/API_DependencyControllerTests.swift @@ -18,7 +18,7 @@ import Testing import Vapor -@Suite struct API_DependencyControllerTests { +extension AllTests.API_DependencyControllerTests { @Test func query() async throws { try await withApp { app in diff --git a/Tests/AppTests/AlertingTests.swift b/Tests/AppTests/AlertingTests.swift index bceb89034..acf740ba8 100644 --- a/Tests/AppTests/AlertingTests.swift +++ b/Tests/AppTests/AlertingTests.swift @@ -18,7 +18,7 @@ import Dependencies import Testing -@Suite struct AlertingTests { +extension AllTests.AlertingTests { @Test func validatePlatformsPresent() throws { let all = Build.Platform.allCases.map { diff --git a/Tests/AppTests/AllTests.swift b/Tests/AppTests/AllTests.swift new file mode 100644 index 000000000..1b10052c9 --- /dev/null +++ b/Tests/AppTests/AllTests.swift @@ -0,0 +1,121 @@ +// Copyright Dave Verwer, Sven A. Schmidt, and other contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Testing +import Dependencies + + +@Suite(.dependency(\.date.now, .t0)) struct AllTests { } + + +extension AllTests { + @Suite struct AlertingTests { } + @Suite struct AnalyzerTests { } + @Suite struct AnalyzerVersionThrottlingTests { } + @Suite struct API_DependencyControllerTests { } + @Suite struct API_PackageController_GetRoute_ModelTests { } + @Suite struct API_PackageController_GetRouteTests { } + @Suite struct API_PackageControllerTests { } + @Suite struct API_PackageSchemaTests { } + @Suite struct ApiTests { } + @Suite struct AppEnvironmentTests { } + @Suite struct AppTests { } + @Suite struct ArrayExtensionTests { } + @Suite struct ArrayStringExtensionTests { } + @Suite struct ArrayVersionExtensionTests { } + @Suite struct AuthorControllerTests { } + @Suite struct BadgeTests { } + @Suite struct BlogActionsModelTests { } + @Suite struct BuildIndexModelTests { } + @Suite struct BuildMonitorControllerTests { } + @Suite struct BuildMonitorIndexModelTests { } + @Suite struct BuildResultTests { } + @Suite struct BuildShowModelTests { } + @Suite struct BuildTests { } + @Suite struct BuildTriggerTests { } + @Suite struct CustomCollectionControllerTests { } + @Suite struct CustomCollectionTests { } + @Suite struct DefaultStringInterpolationTests { } + @Suite struct DocUploadTests { } + @Suite struct DocumentationPageProcessorTests { } + @Suite struct DocumentationTargetTests { } + @Suite struct EmojiTests { } + @Suite struct ErrorMiddlewareTests { } + @Suite struct ErrorPageModelTests { } + @Suite struct ErrorReportingTests { } + @Suite struct FundingLinkTests { } + @Suite struct GitLiveTests { } + @Suite struct GitTests { } + @Suite struct GithubTests { } + @Suite struct GitlabBuilderTests { } + @Suite struct LiveGitlabBuilderTests { } + @Suite struct HomeIndexModelTests { } + @Suite struct IngestionTests { } + @Suite struct IntExtTests { } + @Suite struct Joined3Tests { } + @Suite struct JoinedQueryBuilderTests { } + @Suite struct JoinedTests { } + @Suite struct KeywordControllerTests { } + @Suite struct LicenseTests { } + @Suite struct LiveTests { } + @Suite struct MaintainerInfoIndexModelTests { } + @Suite struct MaintainerInfoIndexViewTests { } + @Suite struct ManifestTests { } + @Suite struct MastodonTests { } + @Suite struct MetricsTests { } + @Suite struct MiscTests { } + @Suite struct PackageCollectionControllerTests { } + @Suite struct PackageCollectionTests { } + @Suite struct PackageContributorsTests { } + @Suite struct PackageController_BuildsRoute_BuildInfoTests { } + @Suite struct PackageController_BuildsRouteTests { } + @Suite struct PackageController_routesTests { } + @Suite struct PackageInfoTests { } + @Suite struct PackageReadmeModelTests { } + @Suite struct PackageReleasesModelTests { } + @Suite struct PackageResultTests { } + @Suite struct PackageTests { } + @Suite struct PipelineTests { } + @Suite struct PlausibleTests { } + @Suite struct ProductTests { } + @Suite struct QueryPlanTests { } + @Suite struct RSSTests { } + @Suite struct ReAnalyzeVersionsTests { } + @Suite struct RecentViewsTests { } + @Suite struct ReconcilerTests { } + @Suite struct ReferenceTests { } + @Suite struct RepositoryTests { } + @Suite struct ResourceReloadIdentifierTests { } + @Suite struct RoutesTests { } + @Suite struct S3StoreExtensionTests { } + @Suite struct SQLKitExtensionTests { } + @Suite struct ScoreTests { } + @Suite struct SearchFilterTests { } + @Suite struct SearchShowModelAppTests { } + @Suite struct SearchShowModelTests { } + @Suite struct SearchTests { } + @Suite struct ShellOutCommandExtensionTests { } + @Suite struct SignificantBuildsTests { } + @Suite struct SiteURLTests { } + @Suite struct SitemapTests { } + @Suite struct SocialTests { } + @Suite struct StatsTests { } + @Suite struct StringExtTests { } + @Suite struct SwiftVersionTests { } + @Suite struct TargetTests { } + @Suite struct ValidateSPIManifestControllerTests { } + @Suite struct VersionDiffTests { } + @Suite struct VersionTests { } + @Suite struct ViewUtilsTests { } +} diff --git a/Tests/AppTests/AnalyzeErrorTests.swift b/Tests/AppTests/AnalyzeErrorTests.swift index 0a67cefc8..1ec6ece13 100644 --- a/Tests/AppTests/AnalyzeErrorTests.swift +++ b/Tests/AppTests/AnalyzeErrorTests.swift @@ -21,6 +21,13 @@ import Testing import Vapor +extension AllTests { + @Suite struct AnalyzeErrorTests { + let socialPosts = LockIsolated<[String]>([]) + } +} + + // Test analysis error handling. // // This suite of tests ensures that errors in batch analysis do not impact processing @@ -28,13 +35,9 @@ import Vapor // // We analyze two packages where the first package is set up to encounter // various error states and ensure the second package is successfully processed. -@Suite struct AnalyzeErrorTests { - - let badPackageID: Package.Id = .id0 - let goodPackageID: Package.Id = .id1 - - let capturingLogger = CapturingLogger() - let socialPosts = LockIsolated<[String]>([]) +extension AllTests.AnalyzeErrorTests { + var badPackageID: Package.Id { .id0 } + var goodPackageID: Package.Id { .id1 } struct SimulatedError: Error { } @@ -58,10 +61,12 @@ import Vapor } @Test func analyze_refreshCheckout_failed() async throws { - try await withApp(setup, defaultDependencies, logHandler: capturingLogger) { app in + let capturingLogger = CapturingLogger() + try await withApp(setup, defaultDependencies) { app in try await withDependencies { $0.environment.loadSPIManifest = { _ in nil } $0.fileManager.fileExists = { @Sendable _ in true } + $0.logger.set(to: capturingLogger) $0.shell.run = { @Sendable cmd, path in switch cmd { case _ where cmd.description.contains("git clone https://github.com/foo/1"): @@ -90,10 +95,12 @@ import Vapor } @Test func analyze_updateRepository_invalidPackageCachePath() async throws { - try await withApp(setup, defaultDependencies, logHandler: capturingLogger) { app in + let capturingLogger = CapturingLogger() + try await withApp(setup, defaultDependencies) { app in try await withDependencies { $0.environment.loadSPIManifest = { _ in nil } $0.fileManager.fileExists = { @Sendable _ in true } + $0.logger.set(to: capturingLogger) } operation: { // setup let pkg = try await Package.find(badPackageID, on: app.db).unwrap() @@ -118,10 +125,12 @@ import Vapor } @Test func analyze_getPackageInfo_gitCheckout_error() async throws { - try await withApp(setup, defaultDependencies, logHandler: capturingLogger) { app in + let capturingLogger = CapturingLogger() + try await withApp(setup, defaultDependencies) { app in try await withDependencies { $0.environment.loadSPIManifest = { _ in nil } $0.fileManager.fileExists = { @Sendable _ in true } + $0.logger.set(to: capturingLogger) $0.shell.run = { @Sendable cmd, path in switch cmd { case .gitCheckout(branch: "main", quiet: true) where path.hasSuffix("foo-1"): @@ -147,7 +156,8 @@ import Vapor } @Test func analyze_dumpPackage_missing_manifest() async throws { - try await withApp(setup, defaultDependencies, logHandler: capturingLogger) { app in + let capturingLogger = CapturingLogger() + try await withApp(setup, defaultDependencies) { app in try await withDependencies { $0.environment.loadSPIManifest = { _ in nil } $0.fileManager.fileExists = { @Sendable path in @@ -156,6 +166,7 @@ import Vapor } return true } + $0.logger.set(to: capturingLogger) } operation: { // MUT try await Analyze.analyze(client: app.client, @@ -176,7 +187,7 @@ import Vapor } -extension AnalyzeErrorTests { +extension AllTests.AnalyzeErrorTests { #if compiler(>=6.1) #warning("Move this into a trait on @Test") // See https://forums.swift.org/t/converting-xctest-invoketest-to-swift-testing/77692/4 for details @@ -193,7 +204,7 @@ extension AnalyzeErrorTests { } -extension AnalyzeErrorTests { +extension AllTests.AnalyzeErrorTests { func defaultValidation(_ app: Application) async throws { let versions = try await Version.query(on: app.db) .filter(\.$package.$id == goodPackageID) diff --git a/Tests/AppTests/AnalyzerTests.swift b/Tests/AppTests/AnalyzerTests.swift index b2ae249fa..0afde6554 100644 --- a/Tests/AppTests/AnalyzerTests.swift +++ b/Tests/AppTests/AnalyzerTests.swift @@ -26,7 +26,7 @@ import Vapor @preconcurrency import ShellOut -@Suite struct AnalyzerTests { +extension AllTests.AnalyzerTests { @Test func analyze() async throws { // End-to-end test, where we mock at the shell command level (i.e. we @@ -1441,7 +1441,7 @@ import Vapor // Ensure `latest` remains set in case of AppError.noValidVersions // https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/2571 let capturingLogger = CapturingLogger() - try await withApp(logHandler: capturingLogger) { app in + try await withApp { app in try await withDependencies { $0.date.now = .now $0.fileManager.fileExists = { @Sendable _ in true } @@ -1456,6 +1456,7 @@ import Vapor 1\tPerson 2 """ } + $0.logger.set(to: capturingLogger) $0.shell.run = { @Sendable _, _ in return "" } } operation: { let pkgId = UUID() diff --git a/Tests/AppTests/AnalyzerVersionThrottlingTests.swift b/Tests/AppTests/AnalyzerVersionThrottlingTests.swift index 9d1a0154e..e656b682c 100644 --- a/Tests/AppTests/AnalyzerVersionThrottlingTests.swift +++ b/Tests/AppTests/AnalyzerVersionThrottlingTests.swift @@ -20,7 +20,7 @@ import Dependencies import Testing -@Suite struct AnalyzerVersionThrottlingTests { +extension AllTests.AnalyzerVersionThrottlingTests { @Test func throttle_keep_old() async throws { // Test keeping old when within throttling window diff --git a/Tests/AppTests/ApiTests.swift b/Tests/AppTests/ApiTests.swift index f4c6f0fcc..906232bc0 100644 --- a/Tests/AppTests/ApiTests.swift +++ b/Tests/AppTests/ApiTests.swift @@ -21,7 +21,7 @@ import Testing import XCTVapor -@Suite struct ApiTests { +extension AllTests.ApiTests { @Test func version() async throws { try await withApp { app in @@ -1181,7 +1181,7 @@ private extension HTTPHeaders { } -extension ApiTests { +extension AllTests.ApiTests { struct TestEvent: Equatable { var kind: Plausible.Event.Kind var path: Plausible.Path diff --git a/Tests/AppTests/AppEnvironmentTests.swift b/Tests/AppTests/AppEnvironmentTests.swift index be71c4836..29c00e038 100644 --- a/Tests/AppTests/AppEnvironmentTests.swift +++ b/Tests/AppTests/AppEnvironmentTests.swift @@ -19,7 +19,7 @@ import Testing import Vapor -@Suite struct AppEnvironmentTests { +extension AllTests.AppEnvironmentTests { @Test func Filemanager_checkoutsDirectory() throws { withDependencies { diff --git a/Tests/AppTests/AppTests.swift b/Tests/AppTests/AppTests.swift index ddfa64cd3..bc15aa3a5 100644 --- a/Tests/AppTests/AppTests.swift +++ b/Tests/AppTests/AppTests.swift @@ -18,7 +18,7 @@ import Vapor import Testing -@Suite struct AppTests { +extension AllTests.AppTests { @Test func migrations() async throws { try await withApp { app in diff --git a/Tests/AppTests/ArrayExtensionTests.swift b/Tests/AppTests/ArrayExtensionTests.swift index 035745afb..aeda86901 100644 --- a/Tests/AppTests/ArrayExtensionTests.swift +++ b/Tests/AppTests/ArrayExtensionTests.swift @@ -19,7 +19,7 @@ import SPIManifest import Testing -@Suite struct ArrayExtensionTests { +extension AllTests.ArrayExtensionTests { @Test func defaultBranchVersion() throws { #expect( diff --git a/Tests/AppTests/ArrayStringExtensionTests.swift b/Tests/AppTests/ArrayStringExtensionTests.swift index 4da0592e5..aee01dcc4 100644 --- a/Tests/AppTests/ArrayStringExtensionTests.swift +++ b/Tests/AppTests/ArrayStringExtensionTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct ArrayStringExtensionTests { +extension AllTests.ArrayStringExtensionTests { @Test func pluralised() throws { #expect([String]().pluralized() == "None") diff --git a/Tests/AppTests/ArrayVersionExtensionTests.swift b/Tests/AppTests/ArrayVersionExtensionTests.swift index f97842b4e..99665a260 100644 --- a/Tests/AppTests/ArrayVersionExtensionTests.swift +++ b/Tests/AppTests/ArrayVersionExtensionTests.swift @@ -19,7 +19,7 @@ import SemanticVersion import Testing -@Suite struct ArrayVersionExtensionTests { +extension AllTests.ArrayVersionExtensionTests { @Test func Array_canonicalDocumentationTarget() async throws { try await withApp { app in diff --git a/Tests/AppTests/AuthorControllerTests.swift b/Tests/AppTests/AuthorControllerTests.swift index 123f5d4b4..875200374 100644 --- a/Tests/AppTests/AuthorControllerTests.swift +++ b/Tests/AppTests/AuthorControllerTests.swift @@ -19,7 +19,7 @@ import Testing import Vapor -@Suite struct AuthorControllerTests { +extension AllTests.AuthorControllerTests { @Test func query() async throws { try await withApp { app in diff --git a/Tests/AppTests/BadgeTests.swift b/Tests/AppTests/BadgeTests.swift index fd99e1c2a..c42882e8f 100644 --- a/Tests/AppTests/BadgeTests.swift +++ b/Tests/AppTests/BadgeTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct BadgeTests { +extension AllTests.BadgeTests { @Test func badgeMessage_swiftVersions() throws { #expect(Badge.badgeMessage(swiftVersions: [.v1, .v2, .v3, .v4]) == "6.0 | 5.10 | 5.9 | 5.8") diff --git a/Tests/AppTests/BlogActionsModelTests.swift b/Tests/AppTests/BlogActionsModelTests.swift index 0f9604efa..e03f05228 100644 --- a/Tests/AppTests/BlogActionsModelTests.swift +++ b/Tests/AppTests/BlogActionsModelTests.swift @@ -20,7 +20,7 @@ import Dependencies import Testing -@Suite struct BlogActionsModelTests { +extension AllTests.BlogActionsModelTests { @Test func init_loadSummaries() async throws { try withDependencies { diff --git a/Tests/AppTests/BuildIndexModelTests.swift b/Tests/AppTests/BuildIndexModelTests.swift index f3e317853..1334bf8c6 100644 --- a/Tests/AppTests/BuildIndexModelTests.swift +++ b/Tests/AppTests/BuildIndexModelTests.swift @@ -20,7 +20,7 @@ import Plot import Testing -@Suite struct BuildIndexModelTests { +extension AllTests.BuildIndexModelTests { @Test func init_no_name() async throws { // Tests behaviour when we're lacking data diff --git a/Tests/AppTests/BuildMonitorControllerTests.swift b/Tests/AppTests/BuildMonitorControllerTests.swift index 267ce8ee3..8a38f9e0b 100644 --- a/Tests/AppTests/BuildMonitorControllerTests.swift +++ b/Tests/AppTests/BuildMonitorControllerTests.swift @@ -19,7 +19,7 @@ import Testing import Vapor -@Suite struct BuildMonitorControllerTests { +extension AllTests.BuildMonitorControllerTests { @Test func show_owner() async throws { try await withDependencies { diff --git a/Tests/AppTests/BuildMonitorIndexModelTests.swift b/Tests/AppTests/BuildMonitorIndexModelTests.swift index 6e8c3fa26..5a413dd08 100644 --- a/Tests/AppTests/BuildMonitorIndexModelTests.swift +++ b/Tests/AppTests/BuildMonitorIndexModelTests.swift @@ -18,7 +18,7 @@ import Plot import Testing -@Suite struct BuildMonitorIndexModelTests { +extension AllTests.BuildMonitorIndexModelTests { @Test func init_from_Build() async throws { try await withApp { app in diff --git a/Tests/AppTests/BuildResultTests.swift b/Tests/AppTests/BuildResultTests.swift index 502f8c76b..f7894d856 100644 --- a/Tests/AppTests/BuildResultTests.swift +++ b/Tests/AppTests/BuildResultTests.swift @@ -18,7 +18,7 @@ import Testing import Vapor -@Suite struct BuildResultTests { +extension AllTests.BuildResultTests { @Test func query() async throws { try await withApp { app in diff --git a/Tests/AppTests/BuildShowModelTests.swift b/Tests/AppTests/BuildShowModelTests.swift index fa97c8a28..d14f0717a 100644 --- a/Tests/AppTests/BuildShowModelTests.swift +++ b/Tests/AppTests/BuildShowModelTests.swift @@ -18,7 +18,7 @@ import Testing import Vapor -@Suite struct BuildShowModelTests { +extension AllTests.BuildShowModelTests { typealias Model = BuildShow.Model diff --git a/Tests/AppTests/BuildTests.swift b/Tests/AppTests/BuildTests.swift index 150bc26b8..2e37eae64 100644 --- a/Tests/AppTests/BuildTests.swift +++ b/Tests/AppTests/BuildTests.swift @@ -24,7 +24,7 @@ import Testing import Vapor -@Suite struct BuildTests { +extension AllTests.BuildTests { @Test func save() async throws { try await withApp { app in diff --git a/Tests/AppTests/BuildTriggerTests.swift b/Tests/AppTests/BuildTriggerTests.swift index 8498e7e42..dcf56a4ea 100644 --- a/Tests/AppTests/BuildTriggerTests.swift +++ b/Tests/AppTests/BuildTriggerTests.swift @@ -24,7 +24,7 @@ import SQLKit import Vapor -@Suite struct BuildTriggerTests { +extension AllTests.BuildTriggerTests { @Test func BuildTriggerInfo_emptyPair() throws { #expect(BuildTriggerInfo(versionId: .id0, buildPairs: Set([BuildPair(.iOS, .v1)])) != nil) diff --git a/Tests/AppTests/CustomCollectionControllerTests.swift b/Tests/AppTests/CustomCollectionControllerTests.swift index c52df5d00..67276f457 100644 --- a/Tests/AppTests/CustomCollectionControllerTests.swift +++ b/Tests/AppTests/CustomCollectionControllerTests.swift @@ -20,7 +20,7 @@ import Testing import Vapor -@Suite struct CustomCollectionControllerTests { +extension AllTests.CustomCollectionControllerTests { @Test func query() async throws { try await withApp { app in diff --git a/Tests/AppTests/CustomCollectionTests.swift b/Tests/AppTests/CustomCollectionTests.swift index 18bba4498..218bac530 100644 --- a/Tests/AppTests/CustomCollectionTests.swift +++ b/Tests/AppTests/CustomCollectionTests.swift @@ -20,7 +20,7 @@ import Dependencies import Testing -@Suite struct CustomCollectionTests { +extension AllTests.CustomCollectionTests { @Test func CustomCollection_save() async throws { try await withApp { app in diff --git a/Tests/AppTests/DefaultStringInterpolationTests.swift b/Tests/AppTests/DefaultStringInterpolationTests.swift index 4e2d11007..a1a117119 100644 --- a/Tests/AppTests/DefaultStringInterpolationTests.swift +++ b/Tests/AppTests/DefaultStringInterpolationTests.swift @@ -19,7 +19,7 @@ import Foundation import Testing -@Suite struct DefaultStringInterpolationTests { +extension AllTests.DefaultStringInterpolationTests { @Test func inWords_timeDifference() throws { let m = 60 diff --git a/Tests/AppTests/DocUploadTests.swift b/Tests/AppTests/DocUploadTests.swift index 1ef809a4b..771d8957a 100644 --- a/Tests/AppTests/DocUploadTests.swift +++ b/Tests/AppTests/DocUploadTests.swift @@ -19,7 +19,7 @@ import Foundation import PostgresKit import Testing -@Suite struct DocUploadTests { +extension AllTests.DocUploadTests { @Test func attach() async throws { try await withApp { app in diff --git a/Tests/AppTests/DocumentationPageProcessorTests.swift b/Tests/AppTests/DocumentationPageProcessorTests.swift index 966394abb..5e2b5d812 100644 --- a/Tests/AppTests/DocumentationPageProcessorTests.swift +++ b/Tests/AppTests/DocumentationPageProcessorTests.swift @@ -20,7 +20,7 @@ import SwiftSoup import Testing -@Suite struct DocumentationPageProcessorTests { +extension AllTests.DocumentationPageProcessorTests { @Test func header_linkTitle() throws { // https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/2249 diff --git a/Tests/AppTests/DocumentationTargetTests.swift b/Tests/AppTests/DocumentationTargetTests.swift index dd9aa1896..da5253e42 100644 --- a/Tests/AppTests/DocumentationTargetTests.swift +++ b/Tests/AppTests/DocumentationTargetTests.swift @@ -19,7 +19,7 @@ import Foundation import Testing -@Suite struct DocumentationTargetTests { +extension AllTests.DocumentationTargetTests { @Test func external() async throws { // Test external doc url lookup diff --git a/Tests/AppTests/EmojiTests.swift b/Tests/AppTests/EmojiTests.swift index b4310a706..511f1ca74 100644 --- a/Tests/AppTests/EmojiTests.swift +++ b/Tests/AppTests/EmojiTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct EmojiTests { +extension AllTests.EmojiTests { @Test func emojiReplacement() throws { let cases: [(shorthand: String, result: String)] = [ diff --git a/Tests/AppTests/ErrorMiddlewareTests.swift b/Tests/AppTests/ErrorMiddlewareTests.swift index 6e348145b..fdc623b61 100644 --- a/Tests/AppTests/ErrorMiddlewareTests.swift +++ b/Tests/AppTests/ErrorMiddlewareTests.swift @@ -19,7 +19,7 @@ import Testing import Vapor -@Suite struct ErrorMiddlewareTests { +extension AllTests.ErrorMiddlewareTests { func setup(_ app: Application) async throws { // set up some test routes diff --git a/Tests/AppTests/ErrorPageModelTests.swift b/Tests/AppTests/ErrorPageModelTests.swift index 838e43320..ca478ed0b 100644 --- a/Tests/AppTests/ErrorPageModelTests.swift +++ b/Tests/AppTests/ErrorPageModelTests.swift @@ -18,7 +18,7 @@ import Testing import Vapor -@Suite struct ErrorPageModelTests { +extension AllTests.ErrorPageModelTests { @Test func error_500() throws { // setup diff --git a/Tests/AppTests/ErrorReportingTests.swift b/Tests/AppTests/ErrorReportingTests.swift index f3fb5905b..a05b1e60c 100644 --- a/Tests/AppTests/ErrorReportingTests.swift +++ b/Tests/AppTests/ErrorReportingTests.swift @@ -20,9 +20,7 @@ import Dependencies import Testing -@Suite struct ErrorReportingTests { - - let capturingLogger = CapturingLogger() +extension AllTests.ErrorReportingTests { @Test func Analyze_recordError() async throws { try await withApp { app in @@ -38,13 +36,15 @@ import Testing } @Test func Ingestion_error_reporting() async throws { - try await withApp(logHandler: capturingLogger) { app in + let capturingLogger = CapturingLogger() + try await withApp { app in // setup try await Package(id: .id0, url: "1", processingStage: .reconciliation).save(on: app.db) try await withDependencies { $0.date.now = .now $0.github.fetchMetadata = { @Sendable _, _ throws(Github.Error) in throw Github.Error.invalidURL("1") } + $0.logger.set(to: capturingLogger) } operation: { // MUT try await Ingestion.ingest(client: app.client, database: app.db, mode: .limit(10)) @@ -59,16 +59,18 @@ import Testing } @Test func Analyzer_error_reporting() async throws { - try await withDependencies { - $0.fileManager.fileExists = { @Sendable _ in true } - $0.shell.run = { @Sendable cmd, _ in - if cmd.description == "git tag" { return "1.0.0" } - // returning a blank string will cause an exception when trying to - // decode it as the manifest result - we use this to simulate errors - return "invalid" - } - } operation: { - try await withApp(logHandler: capturingLogger) { app in + try await withApp { app in + let capturingLogger = CapturingLogger() + try await withDependencies { + $0.fileManager.fileExists = { @Sendable _ in true } + $0.logger.set(to: capturingLogger) + $0.shell.run = { @Sendable cmd, _ in + if cmd.description == "git tag" { return "1.0.0" } + // returning a blank string will cause an exception when trying to + // decode it as the manifest result - we use this to simulate errors + return "invalid" + } + } operation: { // setup try await Package(id: .id1, url: "1".asGithubUrl.url, processingStage: .ingestion).save(on: app.db) diff --git a/Tests/AppTests/FundingLinkTests.swift b/Tests/AppTests/FundingLinkTests.swift index 294613422..eabb61ce8 100644 --- a/Tests/AppTests/FundingLinkTests.swift +++ b/Tests/AppTests/FundingLinkTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct FundingLinkTests { +extension AllTests.FundingLinkTests { @Test func fundingLink_missingSchemeFix() async throws { // URL with both a scheme and a host. diff --git a/Tests/AppTests/GitLiveTests.swift b/Tests/AppTests/GitLiveTests.swift index e822cd513..51773d08b 100644 --- a/Tests/AppTests/GitLiveTests.swift +++ b/Tests/AppTests/GitLiveTests.swift @@ -21,7 +21,7 @@ import ShellOut import Testing -@Suite struct GitLiveTests { +extension AllTests.GitLiveTests { @Test func commitCount() async throws { try await withGitRepository(defaultDependencies) { path throws in @@ -116,7 +116,7 @@ private func withGitRepository( } -extension GitLiveTests { +extension AllTests.GitLiveTests { #if compiler(>=6.1) #warning("Move this into a trait on @Test") // See https://forums.swift.org/t/converting-xctest-invoketest-to-swift-testing/77692/4 for details diff --git a/Tests/AppTests/GitTests.swift b/Tests/AppTests/GitTests.swift index 6a256b5d1..b49350305 100644 --- a/Tests/AppTests/GitTests.swift +++ b/Tests/AppTests/GitTests.swift @@ -21,7 +21,7 @@ import ShellOut import Testing -@Suite struct GitTests { +extension AllTests.GitTests { @Test func tag() async throws { try await withDependencies { diff --git a/Tests/AppTests/GithubTests.swift b/Tests/AppTests/GithubTests.swift index 0a17bf269..4e8ee5b03 100644 --- a/Tests/AppTests/GithubTests.swift +++ b/Tests/AppTests/GithubTests.swift @@ -22,7 +22,7 @@ import Testing import Vapor -@Suite struct GithubTests { +extension AllTests.GithubTests { @Test func parseOwnerName() throws { do { diff --git a/Tests/AppTests/GitlabBuilderTests.swift b/Tests/AppTests/GitlabBuilderTests.swift index 6ac4f0245..dc04f74e6 100644 --- a/Tests/AppTests/GitlabBuilderTests.swift +++ b/Tests/AppTests/GitlabBuilderTests.swift @@ -19,7 +19,7 @@ import Testing import Vapor -@Suite struct GitlabBuilderTests { +extension AllTests.GitlabBuilderTests { @Test func SwiftVersion_rendering() throws { #expect("\(SwiftVersion.v4)" == "6.0.0") @@ -154,56 +154,3 @@ import Vapor } } - - -@Suite - - -struct LiveGitlabBuilderTests { - - @Test( - .disabled("This is a live trigger test for end-to-end testing of pre-release builder versions") - ) - func triggerBuild_live() async throws { - try await withDependencies { - // make sure environment variables are configured for live access - $0.environment.awsDocsBucket = { "spi-dev-docs" } - $0.environment.builderToken = { - // Set this to a valid value if you want to report build results back to the server - ProcessInfo.processInfo.environment["LIVE_BUILDER_TOKEN"] - } - $0.environment.buildTimeout = { 10 } - $0.environment.gitlabPipelineToken = { - // This Gitlab token is required in order to trigger the pipeline - ProcessInfo.processInfo.environment["LIVE_GITLAB_PIPELINE_TOKEN"] - } - $0.environment.siteURL = { "https://staging.swiftpackageindex.com" } - $0.httpClient = .liveValue - } operation: { - // set build branch to trigger on - Gitlab.Builder.branch = "main" - - let buildId = UUID() - - // use a valid uuid from a live db if reporting back should succeed - // SemanticVersion 0.3.2 on staging - let versionID = UUID(uuidString: "93d8c545-15c4-43c2-946f-1b625e2596f9")! - - // MUT - let res = try await Gitlab.Builder.triggerBuild( - buildId: buildId, - cloneURL: "https://github.com/SwiftPackageIndex/SemanticVersion.git", - isDocBuild: false, - platform: .macosSpm, - reference: .tag(.init(0, 3, 2)), - swiftVersion: .v4, - versionID: versionID - ) - - print("status: \(res.status)") - print("buildId: \(buildId)") - print("webUrl: \(res.webUrl)") - } - } - -} diff --git a/Tests/AppTests/Helpers/TestSupport.swift b/Tests/AppTests/Helpers/TestSupport.swift index 4e6ad5af9..d4128a133 100644 --- a/Tests/AppTests/Helpers/TestSupport.swift +++ b/Tests/AppTests/Helpers/TestSupport.swift @@ -21,7 +21,6 @@ import PostgresNIO func withApp(_ setup: (Application) async throws -> Void = { _ in }, _ updateValuesForOperation: (inout DependencyValues) async throws -> Void = { _ in }, - logHandler: LogHandler? = nil, environment: Environment = .testing, _ test: (Application) async throws -> Void) async throws { try await TestSupport.setupDb(environment) @@ -30,11 +29,7 @@ func withApp(_ setup: (Application) async throws -> Void = { _ in }, return try await run { try await setup(app) try await withDependencies(updateValuesForOperation) { - try await withDependencies { - $0.logger.set(to: logHandler) - } operation: { - try await test(app) - } + try await test(app) } } defer: { try await app.asyncShutdown() diff --git a/Tests/AppTests/HomeIndexModelTests.swift b/Tests/AppTests/HomeIndexModelTests.swift index 63830a660..bb7d620bf 100644 --- a/Tests/AppTests/HomeIndexModelTests.swift +++ b/Tests/AppTests/HomeIndexModelTests.swift @@ -20,7 +20,7 @@ import Dependencies import Testing -@Suite struct HomeIndexModelTests { +extension AllTests.HomeIndexModelTests { @Test func query() async throws { try await withApp { app in diff --git a/Tests/AppTests/IngestionTests.swift b/Tests/AppTests/IngestionTests.swift index 5613338ae..c56e239a5 100644 --- a/Tests/AppTests/IngestionTests.swift +++ b/Tests/AppTests/IngestionTests.swift @@ -21,7 +21,7 @@ import Testing import Vapor -@Suite struct IngestionTests { +extension AllTests.IngestionTests { @Test func ingest_basic() async throws { try await withApp { app in @@ -383,7 +383,7 @@ import Vapor // Test error behaviour when two packages resolving to the same owner/name are ingested: // - don't create repository records let capturingLogger = CapturingLogger() - try await withApp(logHandler: capturingLogger) { app in + try await withApp { app in // setup try await Package(id: .id0, url: "https://github.com/foo/0", status: .ok, processingStage: .reconciliation) .save(on: app.db) @@ -413,6 +413,7 @@ import Vapor summary: "desc") } $0.github.fetchReadme = { @Sendable _, _ in nil } + $0.logger.set(to: capturingLogger) } operation: { // MUT try await Ingestion.ingest(client: app.client, database: app.db, mode: .limit(10)) diff --git a/Tests/AppTests/IntExtTests.swift b/Tests/AppTests/IntExtTests.swift index f3619e52f..d20e5f77d 100644 --- a/Tests/AppTests/IntExtTests.swift +++ b/Tests/AppTests/IntExtTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct IntExtTests { +extension AllTests.IntExtTests { @Test func pluralizedCount() throws { #expect(0.labeled("executable") == "no executables") diff --git a/Tests/AppTests/Joined3Tests.swift b/Tests/AppTests/Joined3Tests.swift index 1490ce339..3918335fd 100644 --- a/Tests/AppTests/Joined3Tests.swift +++ b/Tests/AppTests/Joined3Tests.swift @@ -18,7 +18,7 @@ import Testing import Vapor -@Suite struct Joined3Tests { +extension AllTests.Joined3Tests { @Test func query_no_version() async throws { try await withApp { app in diff --git a/Tests/AppTests/JoinedQueryBuilderTests.swift b/Tests/AppTests/JoinedQueryBuilderTests.swift index 158456911..795f7e0e5 100644 --- a/Tests/AppTests/JoinedQueryBuilderTests.swift +++ b/Tests/AppTests/JoinedQueryBuilderTests.swift @@ -22,7 +22,7 @@ import Testing /// and forwards method calls to it. This test class tests this behaviour in principle for `sort` /// but not for any other methods at this time, because the instrumentation is quite mechanical /// and essentially compiler checked. -@Suite struct JoinedQueryBuilderTests { +extension AllTests.JoinedQueryBuilderTests { @Test func sort() async throws { try await withApp { app in diff --git a/Tests/AppTests/JoinedTests.swift b/Tests/AppTests/JoinedTests.swift index 351915032..0ad9c201b 100644 --- a/Tests/AppTests/JoinedTests.swift +++ b/Tests/AppTests/JoinedTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct JoinedTests { +extension AllTests.JoinedTests { typealias JPR = Joined @Test func query_owner_repository() async throws { diff --git a/Tests/AppTests/KeywordControllerTests.swift b/Tests/AppTests/KeywordControllerTests.swift index 90f194961..665a4d942 100644 --- a/Tests/AppTests/KeywordControllerTests.swift +++ b/Tests/AppTests/KeywordControllerTests.swift @@ -19,7 +19,7 @@ import Testing import XCTVapor -@Suite struct KeywordControllerTests { +extension AllTests.KeywordControllerTests { @Test func query() async throws { try await withApp { app in diff --git a/Tests/AppTests/LicenseTests.swift b/Tests/AppTests/LicenseTests.swift index cfc73b537..c5c6074bb 100644 --- a/Tests/AppTests/LicenseTests.swift +++ b/Tests/AppTests/LicenseTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct LicenseTests { +extension AllTests.LicenseTests { @Test func init_from_dto() throws { #expect(License(from: Github.Metadata.LicenseInfo(key: "mit")) == .mit) diff --git a/Tests/AppTests/LiveGitlabBuilderTests.swift b/Tests/AppTests/LiveGitlabBuilderTests.swift new file mode 100644 index 000000000..bb9d9c210 --- /dev/null +++ b/Tests/AppTests/LiveGitlabBuilderTests.swift @@ -0,0 +1,70 @@ +// Copyright Dave Verwer, Sven A. Schmidt, and other contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Foundation + +@testable import App + +import Dependencies +import Testing + + +extension AllTests.LiveGitlabBuilderTests { + + @Test( + .disabled("This is a live trigger test for end-to-end testing of pre-release builder versions") + ) + func triggerBuild_live() async throws { + try await withDependencies { + // make sure environment variables are configured for live access + $0.environment.awsDocsBucket = { "spi-dev-docs" } + $0.environment.builderToken = { + // Set this to a valid value if you want to report build results back to the server + ProcessInfo.processInfo.environment["LIVE_BUILDER_TOKEN"] + } + $0.environment.buildTimeout = { 10 } + $0.environment.gitlabPipelineToken = { + // This Gitlab token is required in order to trigger the pipeline + ProcessInfo.processInfo.environment["LIVE_GITLAB_PIPELINE_TOKEN"] + } + $0.environment.siteURL = { "https://staging.swiftpackageindex.com" } + $0.httpClient = .liveValue + } operation: { + // set build branch to trigger on + Gitlab.Builder.branch = "main" + + let buildId = UUID() + + // use a valid uuid from a live db if reporting back should succeed + // SemanticVersion 0.3.2 on staging + let versionID = UUID(uuidString: "93d8c545-15c4-43c2-946f-1b625e2596f9")! + + // MUT + let res = try await Gitlab.Builder.triggerBuild( + buildId: buildId, + cloneURL: "https://github.com/SwiftPackageIndex/SemanticVersion.git", + isDocBuild: false, + platform: .macosSpm, + reference: .tag(.init(0, 3, 2)), + swiftVersion: .v4, + versionID: versionID + ) + + print("status: \(res.status)") + print("buildId: \(buildId)") + print("webUrl: \(res.webUrl)") + } + } + +} diff --git a/Tests/AppTests/LiveTests.swift b/Tests/AppTests/LiveTests.swift index d9ad5b06a..323cd697c 100644 --- a/Tests/AppTests/LiveTests.swift +++ b/Tests/AppTests/LiveTests.swift @@ -21,7 +21,7 @@ import Testing import Vapor -@Suite struct LiveTests { +extension AllTests.LiveTests { @Test( .disabled("Only run this test manually to confirm posting works") diff --git a/Tests/AppTests/MaintainerInfoIndexModelTests.swift b/Tests/AppTests/MaintainerInfoIndexModelTests.swift index c240aea0a..fdf8b0652 100644 --- a/Tests/AppTests/MaintainerInfoIndexModelTests.swift +++ b/Tests/AppTests/MaintainerInfoIndexModelTests.swift @@ -20,8 +20,7 @@ import SnapshotTesting import Testing -@Suite(.dependency(\.date.now, .t0)) -struct MaintainerInfoIndexModelTests { +extension AllTests.MaintainerInfoIndexModelTests { @Test func badgeURL() throws { withDependencies { diff --git a/Tests/AppTests/MaintainerInfoIndexViewTests.swift b/Tests/AppTests/MaintainerInfoIndexViewTests.swift index 72a0812a4..333ed1f0f 100644 --- a/Tests/AppTests/MaintainerInfoIndexViewTests.swift +++ b/Tests/AppTests/MaintainerInfoIndexViewTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct MaintainerInfoIndexViewTests { +extension AllTests.MaintainerInfoIndexViewTests { @Test func spiManifestCommonUseCasesDocLink() throws { #expect( diff --git a/Tests/AppTests/ManifestTests.swift b/Tests/AppTests/ManifestTests.swift index ea16ff7b6..2df77688c 100644 --- a/Tests/AppTests/ManifestTests.swift +++ b/Tests/AppTests/ManifestTests.swift @@ -19,7 +19,7 @@ import Foundation import Testing -@Suite struct ManifestTests { +extension AllTests.ManifestTests { @Test func decode_Product_Type() throws { // Test product type decoding. diff --git a/Tests/AppTests/MastodonTests.swift b/Tests/AppTests/MastodonTests.swift index 04c9bfa1c..3d3d41189 100644 --- a/Tests/AppTests/MastodonTests.swift +++ b/Tests/AppTests/MastodonTests.swift @@ -19,7 +19,7 @@ import SemanticVersion import Testing -@Suite struct MastodonTests { +extension AllTests.MastodonTests { @Test func apiURL() throws { let url = try Mastodon.apiURL(with: "message") diff --git a/Tests/AppTests/MetricsTests.swift b/Tests/AppTests/MetricsTests.swift index b6eb1f8eb..3d81d52f4 100644 --- a/Tests/AppTests/MetricsTests.swift +++ b/Tests/AppTests/MetricsTests.swift @@ -21,7 +21,7 @@ import Prometheus import Testing -@Suite struct MetricsTests { +extension AllTests.MetricsTests { @Test func basic() async throws { try await withDependencies { diff --git a/Tests/AppTests/MiscTests.swift b/Tests/AppTests/MiscTests.swift index 1b644951a..84b4f5ccb 100644 --- a/Tests/AppTests/MiscTests.swift +++ b/Tests/AppTests/MiscTests.swift @@ -20,7 +20,7 @@ import Testing /// Tests for utilities and extesions that don't each need a full separate test class -@Suite struct MiscTests { +extension AllTests.MiscTests { @Test func Array_queryString() throws { // Single parameter diff --git a/Tests/AppTests/PackageCollectionControllerTests.swift b/Tests/AppTests/PackageCollectionControllerTests.swift index 7ae7d2f0b..496b79298 100644 --- a/Tests/AppTests/PackageCollectionControllerTests.swift +++ b/Tests/AppTests/PackageCollectionControllerTests.swift @@ -21,7 +21,7 @@ import SnapshotTesting import Testing -@Suite struct PackageCollectionControllerTests { +extension AllTests.PackageCollectionControllerTests { @Test( .disabled( @@ -173,7 +173,7 @@ import Testing } -extension PackageCollectionControllerTests { +extension AllTests.PackageCollectionControllerTests { var encoder: JSONEncoder { let e = JSONEncoder() e.outputFormatting = [.prettyPrinted, .sortedKeys] diff --git a/Tests/AppTests/PackageCollectionTests.swift b/Tests/AppTests/PackageCollectionTests.swift index 2d1cb8d92..bcd3ae165 100644 --- a/Tests/AppTests/PackageCollectionTests.swift +++ b/Tests/AppTests/PackageCollectionTests.swift @@ -22,17 +22,17 @@ import Testing import Vapor -@Suite struct PackageCollectionTests { +extension AllTests.PackageCollectionTests { - let encoder: JSONEncoder = { + typealias VersionResult = PackageCollection.VersionResult + typealias VersionResultGroup = PackageCollection.VersionResultGroup + + var encoder: JSONEncoder { let e = JSONEncoder() e.outputFormatting = [.prettyPrinted, .sortedKeys] e.dateEncodingStrategy = .iso8601 return e - }() - - typealias VersionResult = PackageCollection.VersionResult - typealias VersionResultGroup = PackageCollection.VersionResultGroup + } @Test func query_filter_urls() async throws { // Tests PackageResult.query with the url filter option diff --git a/Tests/AppTests/PackageContributorsTests.swift b/Tests/AppTests/PackageContributorsTests.swift index 5ecbb0bd2..2c0abab85 100644 --- a/Tests/AppTests/PackageContributorsTests.swift +++ b/Tests/AppTests/PackageContributorsTests.swift @@ -18,7 +18,7 @@ import Dependencies import Testing -@Suite struct PackageContributorsTests { +extension AllTests.PackageContributorsTests { @Test func packageAuthors_hasAuthors() throws { let noPackageAuthors = PackageAuthors(authors: [], numberOfContributors: 0) diff --git a/Tests/AppTests/PackageController+BuildsRoute+BuildInfoTests.swift b/Tests/AppTests/PackageController+BuildsRoute+BuildInfoTests.swift index 5e77febdb..d8523087e 100644 --- a/Tests/AppTests/PackageController+BuildsRoute+BuildInfoTests.swift +++ b/Tests/AppTests/PackageController+BuildsRoute+BuildInfoTests.swift @@ -18,7 +18,7 @@ import Testing import Vapor -@Suite struct PackageController_BuildsRoute_BuildInfoTests { +extension AllTests.PackageController_BuildsRoute_BuildInfoTests { @Test func buildStatus() throws { // Test build status aggregation, in particular see diff --git a/Tests/AppTests/PackageController+BuildsRouteTests.swift b/Tests/AppTests/PackageController+BuildsRouteTests.swift index 9392e182a..b6ce93068 100644 --- a/Tests/AppTests/PackageController+BuildsRouteTests.swift +++ b/Tests/AppTests/PackageController+BuildsRouteTests.swift @@ -18,7 +18,7 @@ import Testing import Vapor -@Suite struct PackageController_BuildsRouteTests { +extension AllTests.PackageController_BuildsRouteTests { typealias BuildDetails = (id: Build.Id, reference: Reference, platform: Build.Platform, swiftVersion: SwiftVersion, status: Build.Status, docStatus: DocUpload.Status?) diff --git a/Tests/AppTests/PackageController+routesTests.swift b/Tests/AppTests/PackageController+routesTests.swift index f95c47d3b..2e21b6fed 100644 --- a/Tests/AppTests/PackageController+routesTests.swift +++ b/Tests/AppTests/PackageController+routesTests.swift @@ -21,7 +21,7 @@ import Testing import Vapor -@Suite struct PackageController_routesTests { +extension AllTests.PackageController_routesTests { @Test func show() async throws { try await withDependencies { diff --git a/Tests/AppTests/PackageInfoTests.swift b/Tests/AppTests/PackageInfoTests.swift index c9197ecdb..3b53ca598 100644 --- a/Tests/AppTests/PackageInfoTests.swift +++ b/Tests/AppTests/PackageInfoTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct PackageInfoTests { +extension AllTests.PackageInfoTests { @Test func title_package_name() async throws { // Ensure title is populated from package.name() diff --git a/Tests/AppTests/PackageReadmeModelTests.swift b/Tests/AppTests/PackageReadmeModelTests.swift index 07483d41a..6019390a1 100644 --- a/Tests/AppTests/PackageReadmeModelTests.swift +++ b/Tests/AppTests/PackageReadmeModelTests.swift @@ -21,7 +21,7 @@ import SwiftSoup import Testing -@Suite struct PackageReadmeModelTests { +extension AllTests.PackageReadmeModelTests { @Test func Element_extractReadme() throws { let element = Element.extractReadme(""" diff --git a/Tests/AppTests/PackageReleasesModelTests.swift b/Tests/AppTests/PackageReleasesModelTests.swift index 31541aef5..13f0cbb00 100644 --- a/Tests/AppTests/PackageReleasesModelTests.swift +++ b/Tests/AppTests/PackageReleasesModelTests.swift @@ -20,7 +20,7 @@ import Dependencies import Testing -@Suite struct PackageReleasesModelTests { +extension AllTests.PackageReleasesModelTests { @Test func initialise() async throws { // Setup diff --git a/Tests/AppTests/PackageResultTests.swift b/Tests/AppTests/PackageResultTests.swift index c5f6d2ec2..4a2da4b85 100644 --- a/Tests/AppTests/PackageResultTests.swift +++ b/Tests/AppTests/PackageResultTests.swift @@ -18,7 +18,7 @@ import SemanticVersion import Testing -@Suite struct PackageResultTests { +extension AllTests.PackageResultTests { typealias PackageResult = PackageController.PackageResult @Test func joined5() async throws { diff --git a/Tests/AppTests/PackageTests.swift b/Tests/AppTests/PackageTests.swift index a8ffe47bc..7d4e5dd5a 100644 --- a/Tests/AppTests/PackageTests.swift +++ b/Tests/AppTests/PackageTests.swift @@ -21,7 +21,7 @@ import Testing import Vapor -@Suite struct PackageTests { +extension AllTests.PackageTests { @Test func Equatable() throws { #expect(Package(id: .id0, url: "1".url) == Package(id: .id0, url: "2".url)) diff --git a/Tests/AppTests/PipelineTests.swift b/Tests/AppTests/PipelineTests.swift index 44b4cc11e..984bc352c 100644 --- a/Tests/AppTests/PipelineTests.swift +++ b/Tests/AppTests/PipelineTests.swift @@ -24,7 +24,7 @@ import Vapor // - candidate selection at each stage // - processing stage recording // - error recording -@Suite struct PipelineTests { +extension AllTests.PipelineTests { @Test func fetchCandidates_ingestion_fifo() async throws { // oldest first diff --git a/Tests/AppTests/PlausibleTests.swift b/Tests/AppTests/PlausibleTests.swift index 8cf46548a..ee7124389 100644 --- a/Tests/AppTests/PlausibleTests.swift +++ b/Tests/AppTests/PlausibleTests.swift @@ -20,7 +20,7 @@ import Dependencies import Testing -@Suite struct PlausibleTests { +extension AllTests.PlausibleTests { @Test func User_identifier() throws { #expect(User.api(for: "token") == .init(name: "api", identifier: "3c469e9d")) diff --git a/Tests/AppTests/ProductTests.swift b/Tests/AppTests/ProductTests.swift index 51ddabdf0..0b0d57900 100644 --- a/Tests/AppTests/ProductTests.swift +++ b/Tests/AppTests/ProductTests.swift @@ -19,7 +19,7 @@ import Foundation import Testing -@Suite struct ProductTests { +extension AllTests.ProductTests { @Test func ProductType_Codable() throws { // Ensure ProductType is Codable in a way that's forward compatible with Swift 5.5's Codable synthesis for enums with associated types (SE-0295) diff --git a/Tests/AppTests/QueryPerformanceTests.swift b/Tests/AppTests/QueryPerformanceTests.swift index ec3a8a5d6..78a1f2298 100644 --- a/Tests/AppTests/QueryPerformanceTests.swift +++ b/Tests/AppTests/QueryPerformanceTests.swift @@ -20,12 +20,17 @@ import Testing import Vapor -@Suite( - .serialized, - .tags(.performance), - .disabled(if: !runQueryPerformanceTests()) -) -struct QueryPerformanceTests { +extension AllTests { + @Suite( + .serialized, + .tags(.performance), + .disabled(if: !runQueryPerformanceTests()) + ) + struct QueryPerformanceTests { } +} + + +extension AllTests.QueryPerformanceTests { // Set this to true when running locally to convert warnings to test failures for easier updating of values. static let failOnWarning = false @@ -220,7 +225,7 @@ extension SQLQueryBuilder { } -private extension QueryPerformanceTests { +private extension AllTests.QueryPerformanceTests { func assertQueryPerformance(_ query: SQLQueryBuilder, expectedCost: Double, diff --git a/Tests/AppTests/QueryPlanTests.swift b/Tests/AppTests/QueryPlanTests.swift index 07fc88881..f468c2a4c 100644 --- a/Tests/AppTests/QueryPlanTests.swift +++ b/Tests/AppTests/QueryPlanTests.swift @@ -19,7 +19,7 @@ import Testing @preconcurrency import Parsing -@Suite struct QueryPlanTests { +extension AllTests.QueryPlanTests { @Test func cost_parse() throws { #expect( diff --git a/Tests/AppTests/RSSTests.swift b/Tests/AppTests/RSSTests.swift index dde77d14e..51ea9b297 100644 --- a/Tests/AppTests/RSSTests.swift +++ b/Tests/AppTests/RSSTests.swift @@ -21,7 +21,7 @@ import SnapshotTesting import Testing -@Suite struct RSSTests { +extension AllTests.RSSTests { @Test func recentPackage_rssGuid() throws { let recentPackage = RecentPackage.mock(repositoryOwner: "owner", repositoryName: "name") diff --git a/Tests/AppTests/ReAnalyzeVersionsTests.swift b/Tests/AppTests/ReAnalyzeVersionsTests.swift index 05c49a84b..303f40948 100644 --- a/Tests/AppTests/ReAnalyzeVersionsTests.swift +++ b/Tests/AppTests/ReAnalyzeVersionsTests.swift @@ -21,7 +21,7 @@ import Testing import Vapor -@Suite struct ReAnalyzeVersionsTests { +extension AllTests.ReAnalyzeVersionsTests { @Test func reAnalyzeVersions() async throws { // Basic end-to-end test diff --git a/Tests/AppTests/RecentViewsTests.swift b/Tests/AppTests/RecentViewsTests.swift index 2d6f57843..049879d4a 100644 --- a/Tests/AppTests/RecentViewsTests.swift +++ b/Tests/AppTests/RecentViewsTests.swift @@ -19,7 +19,7 @@ import Foundation import Testing -@Suite struct RecentViewsTests { +extension AllTests.RecentViewsTests { @Test func recentPackages() async throws { try await withApp { app in diff --git a/Tests/AppTests/ReconcilerTests.swift b/Tests/AppTests/ReconcilerTests.swift index 980c295b2..3daa8080b 100644 --- a/Tests/AppTests/ReconcilerTests.swift +++ b/Tests/AppTests/ReconcilerTests.swift @@ -19,7 +19,7 @@ import Testing import Vapor -@Suite struct ReconcilerTests { +extension AllTests.ReconcilerTests { @Test func fetchCurrentPackageList() async throws { try await withApp { app in diff --git a/Tests/AppTests/ReferenceTests.swift b/Tests/AppTests/ReferenceTests.swift index 458c1fae3..586ddaed1 100644 --- a/Tests/AppTests/ReferenceTests.swift +++ b/Tests/AppTests/ReferenceTests.swift @@ -20,7 +20,7 @@ import SemanticVersion import Testing -@Suite struct ReferenceTests { +extension AllTests.ReferenceTests { @Test func Refernce_init() throws { #expect(Reference("1.2.3") == .tag(1, 2, 3)) diff --git a/Tests/AppTests/RepositoryTests.swift b/Tests/AppTests/RepositoryTests.swift index 654e45397..61a517c04 100644 --- a/Tests/AppTests/RepositoryTests.swift +++ b/Tests/AppTests/RepositoryTests.swift @@ -20,7 +20,7 @@ import SQLKit import Testing -@Suite struct RepositoryTests { +extension AllTests.RepositoryTests { @Test func save() async throws { try await withApp { app in diff --git a/Tests/AppTests/ResourceReloadIdentifierTests.swift b/Tests/AppTests/ResourceReloadIdentifierTests.swift index 5844b2d07..7735b16a9 100644 --- a/Tests/AppTests/ResourceReloadIdentifierTests.swift +++ b/Tests/AppTests/ResourceReloadIdentifierTests.swift @@ -19,7 +19,8 @@ import Testing import Vapor -@Suite struct ResourceReloadIdentifierTests { +extension AllTests.ResourceReloadIdentifierTests { + @Test func withAppVersion() throws { withDependencies { $0.environment.appVersion = { "1.2.3" } @@ -27,4 +28,5 @@ import Vapor #expect(ResourceReloadIdentifier.value == "1.2.3") } } + } diff --git a/Tests/AppTests/RoutesTests.swift b/Tests/AppTests/RoutesTests.swift index 10e39a66c..cf8b62028 100644 --- a/Tests/AppTests/RoutesTests.swift +++ b/Tests/AppTests/RoutesTests.swift @@ -20,7 +20,7 @@ import Dependencies import Testing -@Suite struct RoutesTests { +extension AllTests.RoutesTests { @Test func documentation_images() async throws { try await withDependencies { diff --git a/Tests/AppTests/S3StoreExtensionTests.swift b/Tests/AppTests/S3StoreExtensionTests.swift index f1371cd7f..3441d90d8 100644 --- a/Tests/AppTests/S3StoreExtensionTests.swift +++ b/Tests/AppTests/S3StoreExtensionTests.swift @@ -19,7 +19,7 @@ import S3Store import Testing -@Suite struct S3StoreExtensionTests { +extension AllTests.S3StoreExtensionTests { @Test func Key_readme() throws { try withDependencies { diff --git a/Tests/AppTests/SQLKitExtensionTests.swift b/Tests/AppTests/SQLKitExtensionTests.swift index 8f3a4e449..1c54a5ae8 100644 --- a/Tests/AppTests/SQLKitExtensionTests.swift +++ b/Tests/AppTests/SQLKitExtensionTests.swift @@ -18,7 +18,7 @@ import SQLKit import Testing -@Suite struct SQLKitExtensionTests { +extension AllTests.SQLKitExtensionTests { @Test func OrderByGroup() async throws { try await withApp { app in diff --git a/Tests/AppTests/ScoreTests.swift b/Tests/AppTests/ScoreTests.swift index 4cc98c4df..ae5339afa 100644 --- a/Tests/AppTests/ScoreTests.swift +++ b/Tests/AppTests/ScoreTests.swift @@ -18,7 +18,7 @@ import DependenciesTestSupport import Testing -@Suite struct ScoreTests { +extension AllTests.ScoreTests { @Test(.dependency(\.date.now, .t0)) func computeBreakdown() throws { diff --git a/Tests/AppTests/SearchFilterTests.swift b/Tests/AppTests/SearchFilterTests.swift index b1e5d389a..a388e96b8 100644 --- a/Tests/AppTests/SearchFilterTests.swift +++ b/Tests/AppTests/SearchFilterTests.swift @@ -19,7 +19,7 @@ import SQLKit import Testing -@Suite struct SearchFilterTests { +extension AllTests.SearchFilterTests { @Test func SearchFilterKey_searchFilter() throws { // Ensure all `SearchFilter.Key`s are wired correctly to their diff --git a/Tests/AppTests/SearchShowModelAppTests.swift b/Tests/AppTests/SearchShowModelAppTests.swift index f087531be..d7f2dfd88 100644 --- a/Tests/AppTests/SearchShowModelAppTests.swift +++ b/Tests/AppTests/SearchShowModelAppTests.swift @@ -20,7 +20,7 @@ import Testing import Vapor -@Suite struct SearchShowModelAppTests { +extension AllTests.SearchShowModelAppTests { @Test func SearchShow_Model_canonicalURLAllowList() async throws { try await withDependencies { diff --git a/Tests/AppTests/SearchShowModelTests.swift b/Tests/AppTests/SearchShowModelTests.swift index 10e23fb18..260d44c47 100644 --- a/Tests/AppTests/SearchShowModelTests.swift +++ b/Tests/AppTests/SearchShowModelTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct SearchShowModelTests { +extension AllTests.SearchShowModelTests { @Test func SearchShow_Model_init() throws { let results: [Search.Result] = .mock() diff --git a/Tests/AppTests/SearchTests.swift b/Tests/AppTests/SearchTests.swift index eb934021f..f2ef02d12 100644 --- a/Tests/AppTests/SearchTests.swift +++ b/Tests/AppTests/SearchTests.swift @@ -21,7 +21,7 @@ import SnapshotTesting import Testing -@Suite struct SearchTests { +extension AllTests.SearchTests { @Test func DBRecord_packageURL() async throws { #expect(Search.DBRecord(matchType: .package, diff --git a/Tests/AppTests/ShellOutCommandExtensionTests.swift b/Tests/AppTests/ShellOutCommandExtensionTests.swift index 1968932f9..bdbd14735 100644 --- a/Tests/AppTests/ShellOutCommandExtensionTests.swift +++ b/Tests/AppTests/ShellOutCommandExtensionTests.swift @@ -18,7 +18,7 @@ import ShellOut import Testing -@Suite struct ShellOutCommandExtensionTests { +extension AllTests.ShellOutCommandExtensionTests { @Test func gitClean() throws { #expect(ShellOutCommand.gitClean.description == "git clean -fdx") diff --git a/Tests/AppTests/SignificantBuildsTests.swift b/Tests/AppTests/SignificantBuildsTests.swift index 92f308633..0066a7246 100644 --- a/Tests/AppTests/SignificantBuildsTests.swift +++ b/Tests/AppTests/SignificantBuildsTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct SignificantBuildsTests { +extension AllTests.SignificantBuildsTests { @Test func swiftVersionCompatibility() throws { // setup diff --git a/Tests/AppTests/SiteURLTests.swift b/Tests/AppTests/SiteURLTests.swift index 9f46eb031..abdfd5436 100644 --- a/Tests/AppTests/SiteURLTests.swift +++ b/Tests/AppTests/SiteURLTests.swift @@ -20,7 +20,7 @@ import Testing import Vapor -@Suite struct SiteURLTests { +extension AllTests.SiteURLTests { @Test func pathComponents_simple() throws { let p = SiteURL.privacy.pathComponents diff --git a/Tests/AppTests/SitemapTests.swift b/Tests/AppTests/SitemapTests.swift index d05857553..5bed26dd8 100644 --- a/Tests/AppTests/SitemapTests.swift +++ b/Tests/AppTests/SitemapTests.swift @@ -23,7 +23,7 @@ import Vapor @preconcurrency import Plot -@Suite struct SitemapTests { +extension AllTests.SitemapTests { @Test(.dependency(\.date.now, .t0)) func siteMapIndex() async throws { diff --git a/Tests/AppTests/SocialTests.swift b/Tests/AppTests/SocialTests.swift index d3e6b0721..9bc68a4bd 100644 --- a/Tests/AppTests/SocialTests.swift +++ b/Tests/AppTests/SocialTests.swift @@ -23,7 +23,7 @@ import Testing import Vapor -@Suite struct SocialTests { +extension AllTests.SocialTests { @Test func versionUpdateMessage() throws { #expect( diff --git a/Tests/AppTests/StatsTests.swift b/Tests/AppTests/StatsTests.swift index 8bff6bae6..a72758d9a 100644 --- a/Tests/AppTests/StatsTests.swift +++ b/Tests/AppTests/StatsTests.swift @@ -19,7 +19,7 @@ import Foundation import Testing -@Suite struct StatsTests { +extension AllTests.StatsTests { @Test func fetch() async throws { try await withApp { app in diff --git a/Tests/AppTests/StringExtTests.swift b/Tests/AppTests/StringExtTests.swift index 3a23c4f98..a6d4f2785 100644 --- a/Tests/AppTests/StringExtTests.swift +++ b/Tests/AppTests/StringExtTests.swift @@ -19,7 +19,7 @@ import Foundation import Testing -@Suite struct StringExtTests { +extension AllTests.StringExtTests { @Test func pluralised() throws { #expect("version".pluralized(for: 0) == "versions") diff --git a/Tests/AppTests/SwiftVersionTests.swift b/Tests/AppTests/SwiftVersionTests.swift index c03806cc2..61453dd6e 100644 --- a/Tests/AppTests/SwiftVersionTests.swift +++ b/Tests/AppTests/SwiftVersionTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct SwiftVersionTests { +extension AllTests.SwiftVersionTests { @Test func swiftVerRegex() throws { #expect(SwiftVersion.swiftVerRegex.matches("1")) diff --git a/Tests/AppTests/TargetTests.swift b/Tests/AppTests/TargetTests.swift index bf7a90232..88820ad2f 100644 --- a/Tests/AppTests/TargetTests.swift +++ b/Tests/AppTests/TargetTests.swift @@ -19,7 +19,7 @@ import Testing import Vapor -@Suite struct TargetTests { +extension AllTests.TargetTests { @Test func save() async throws { try await withApp { app in diff --git a/Tests/AppTests/ValidateSPIManifestControllerTests.swift b/Tests/AppTests/ValidateSPIManifestControllerTests.swift index 95ec58b30..f05940562 100644 --- a/Tests/AppTests/ValidateSPIManifestControllerTests.swift +++ b/Tests/AppTests/ValidateSPIManifestControllerTests.swift @@ -18,7 +18,7 @@ import SPIManifest import Testing -@Suite struct ValidateSPIManifestControllerTests { +extension AllTests.ValidateSPIManifestControllerTests { @Test func validationResult_basic() throws { let yml = ValidateSPIManifest.Model.placeholderManifest diff --git a/Tests/AppTests/VersionDiffTests.swift b/Tests/AppTests/VersionDiffTests.swift index e586c67ea..3fdb4a5f6 100644 --- a/Tests/AppTests/VersionDiffTests.swift +++ b/Tests/AppTests/VersionDiffTests.swift @@ -27,7 +27,7 @@ import Testing // 3) tag is removed // 4) branch is removed // 5) tag is moved -@Suite struct VersionDiffTests { +extension AllTests.VersionDiffTests { @Test func ImmutableReference_diff_1() throws { // Branch changes commit hash diff --git a/Tests/AppTests/VersionTests.swift b/Tests/AppTests/VersionTests.swift index 8e9f99363..da7761ac4 100644 --- a/Tests/AppTests/VersionTests.swift +++ b/Tests/AppTests/VersionTests.swift @@ -20,7 +20,7 @@ import PostgresKit import Testing -@Suite struct VersionTests { +extension AllTests.VersionTests { @Test func save() async throws { try await withApp { app in diff --git a/Tests/AppTests/ViewUtilsTests.swift b/Tests/AppTests/ViewUtilsTests.swift index 40865eb8f..8152b8d17 100644 --- a/Tests/AppTests/ViewUtilsTests.swift +++ b/Tests/AppTests/ViewUtilsTests.swift @@ -17,7 +17,7 @@ import Testing -@Suite struct ViewUtilsTests { +extension AllTests.ViewUtilsTests { @Test func test_listPhrase() throws { // test listing 2 and 3 values diff --git a/Tests/AppTests/WebpageSnapshotTests.swift b/Tests/AppTests/WebpageSnapshotTests.swift index 57c56099d..829d7510f 100644 --- a/Tests/AppTests/WebpageSnapshotTests.swift +++ b/Tests/AppTests/WebpageSnapshotTests.swift @@ -36,7 +36,12 @@ private extension DependenciesProvider { } -@Suite(.dependencies(.default)) struct WebpageSnapshotTests { +extension AllTests { + @Suite(.dependencies(.default)) struct WebpageSnapshotTests { } +} + + +extension AllTests.WebpageSnapshotTests { @Test func HomeIndex_document() throws { Supporters.mock()