diff --git a/Sources/App/Core/Dependencies/LoggerClient.swift b/Sources/App/Core/Dependencies/LoggerClient.swift index b5cd45b59..0ce0ddbcd 100644 --- a/Sources/App/Core/Dependencies/LoggerClient.swift +++ b/Sources/App/Core/Dependencies/LoggerClient.swift @@ -39,6 +39,18 @@ extension LoggerClient { } +#if DEBUG +extension LoggerClient { + func set(to handler: LogHandler?) { + if let handler { + let logger = Logger(label: "test", factory: { _ in handler }) + set(to: logger) + } + } +} +#endif + + extension LoggerClient: DependencyKey { static var liveValue: Self { .init( diff --git a/Tests/AppTests/AppTestCase.swift b/Tests/AppTests/AppTestCase.swift index 5d61b3b4f..c45b81222 100644 --- a/Tests/AppTests/AppTestCase.swift +++ b/Tests/AppTests/AppTestCase.swift @@ -30,7 +30,7 @@ class AppTestCase: XCTestCase { app = try await setup(.testing) @Dependency(\.logger) var logger - logger.set(to: .init(label: "test", factory: { _ in self.logger })) + logger.set(to: self.logger) } func setup(_ environment: Environment) async throws -> Application { diff --git a/Tests/AppTests/GithubTests.swift b/Tests/AppTests/GithubTests.swift index 3d91a21e6..0a17bf269 100644 --- a/Tests/AppTests/GithubTests.swift +++ b/Tests/AppTests/GithubTests.swift @@ -12,40 +12,40 @@ // See the License for the specific language governing permissions and // limitations under the License. -import XCTest - @testable import App import Dependencies +import Logging import S3Store import SwiftSoup +import Testing import Vapor -class GithubTests: AppTestCase { +@Suite struct GithubTests { - func test_parseOwnerName() throws { + @Test func parseOwnerName() throws { do { let res = try Github.parseOwnerName(url: "https://github.com/foo/bar") - XCTAssertEqual(res.owner, "foo") - XCTAssertEqual(res.name, "bar") + #expect(res.owner == "foo") + #expect(res.name == "bar") } do { let res = try Github.parseOwnerName(url: "https://github.com/foo/bar.git") - XCTAssertEqual(res.owner, "foo") - XCTAssertEqual(res.name, "bar") + #expect(res.owner == "foo") + #expect(res.name == "bar") } do { _ = try Github.parseOwnerName(url: "https://github.com/foo/bar/baz") - XCTFail("Expected error") + Issue.record("Expected error") } catch let Github.Error.invalidURL(url) { - XCTAssertEqual(url, "https://github.com/foo/bar/baz") + #expect(url == "https://github.com/foo/bar/baz") } catch { - XCTFail("Unexpected error: \(error)") + Issue.record("Unexpected error: \(error)") } } - func test_decode_Metadata_null() throws { + @Test func decode_Metadata_null() throws { // Ensure missing values don't trip up decoding struct Response: Decodable { var data: Github.Metadata @@ -102,7 +102,7 @@ class GithubTests: AppTestCase { } } - func test_fetchResource() async throws { + @Test func fetchResource() async throws { struct Response: Decodable, Equatable { var data: Data struct Data: Decodable, Equatable { @@ -121,11 +121,11 @@ class GithubTests: AppTestCase { } } operation: { let res = try await Github.fetchResource(Response.self, query: q) - XCTAssertEqual(res, Response(data: .init(viewer: .init(login: "finestructure")))) + #expect(res == Response(data: .init(viewer: .init(login: "finestructure")))) } } - func test_fetchMetadata() async throws { + @Test func fetchMetadata() async throws { let iso8601 = ISO8601DateFormatter() try await withDependencies { @@ -139,25 +139,22 @@ class GithubTests: AppTestCase { repository: "alamofire") // validation - XCTAssertEqual(res.repository?.closedIssues.nodes.first!.closedAt, - iso8601.date(from: "2020-07-17T16:27:10Z")) - XCTAssertEqual(res.repository?.closedPullRequests.nodes.first!.closedAt, - iso8601.date(from: "2021-05-28T15:50:17Z")) - XCTAssertEqual(res.repository?.forkCount, 6727) - XCTAssertEqual(res.repository?.fundingLinks, [ + #expect(res.repository?.closedIssues.nodes.first!.closedAt == iso8601.date(from: "2020-07-17T16:27:10Z")) + #expect(res.repository?.closedPullRequests.nodes.first!.closedAt == iso8601.date(from: "2021-05-28T15:50:17Z")) + #expect(res.repository?.forkCount == 6727) + #expect(res.repository?.fundingLinks == [ .init(platform: .gitHub, url: "https://github.com/Alamofire"), .init(platform: .lfxCrowdfunding, url: "https://crowdfunding.lfx.linuxfoundation.org/projects/alamofire"), ]) - XCTAssertEqual(res.repository?.mergedPullRequests.nodes.first!.closedAt, - iso8601.date(from: "2021-06-07T22:47:01Z")) - XCTAssertEqual(res.repository?.name, "Alamofire") - XCTAssertEqual(res.repository?.owner.name, "Alamofire") - XCTAssertEqual(res.repository?.owner.login, "Alamofire") - XCTAssertEqual(res.repository?.owner.avatarUrl, "https://avatars.githubusercontent.com/u/7774181?v=4") - XCTAssertEqual(res.repository?.openIssues.totalCount, 30) - XCTAssertEqual(res.repository?.openPullRequests.totalCount, 6) - XCTAssertEqual(res.repository?.releases.nodes.count, 20) - XCTAssertEqual(res.repository?.releases.nodes.first, .some( + #expect(res.repository?.mergedPullRequests.nodes.first!.closedAt == iso8601.date(from: "2021-06-07T22:47:01Z")) + #expect(res.repository?.name == "Alamofire") + #expect(res.repository?.owner.name == "Alamofire") + #expect(res.repository?.owner.login == "Alamofire") + #expect(res.repository?.owner.avatarUrl == "https://avatars.githubusercontent.com/u/7774181?v=4") + #expect(res.repository?.openIssues.totalCount == 30) + #expect(res.repository?.openPullRequests.totalCount == 6) + #expect(res.repository?.releases.nodes.count == 20) + #expect(res.repository?.releases.nodes.first == .some( .init(description: "Released on 2020-04-21. All issues associated with this milestone can be found using this [filter](https://github.com/Alamofire/Alamofire/milestone/77?closed=1).\r\n\r\n#### Fixed\r\n- Change in multipart upload creation order.\r\n - Fixed by [Christian Noon](https://github.com/cnoon) in Pull Request [#3438](https://github.com/Alamofire/Alamofire/pull/3438).\r\n- Typo in Alamofire 5 migration guide.\r\n - Fixed by [DevYeom](https://github.com/DevYeom) in Pull Request [#3431](https://github.com/Alamofire/Alamofire/pull/3431).", descriptionHTML: "

mock descriptionHTML", isDraft: false, @@ -165,22 +162,19 @@ class GithubTests: AppTestCase { tagName: "5.4.3", url: "https://github.com/Alamofire/Alamofire/releases/tag/5.4.3") )) - XCTAssertEqual(res.repository?.repositoryTopics.totalCount, 15) - XCTAssertEqual(res.repository?.repositoryTopics.nodes.first?.topic.name, - "networking") - XCTAssertEqual(res.repository?.stargazerCount, 35831) - XCTAssertEqual(res.repository?.isInOrganization, true) - XCTAssertEqual(res.repository?.homepageUrl, "https://swiftpackageindex.com/Alamofire/Alamofire") + #expect(res.repository?.repositoryTopics.totalCount == 15) + #expect(res.repository?.repositoryTopics.nodes.first?.topic.name == "networking") + #expect(res.repository?.stargazerCount == 35831) + #expect(res.repository?.isInOrganization == true) + #expect(res.repository?.homepageUrl == "https://swiftpackageindex.com/Alamofire/Alamofire") // derived properties - XCTAssertEqual(res.repository?.lastIssueClosedAt, - iso8601.date(from: "2021-06-09T00:59:39Z")) + #expect(res.repository?.lastIssueClosedAt == iso8601.date(from: "2021-06-09T00:59:39Z")) // merged date is latest - expect that one to be reported back - XCTAssertEqual(res.repository?.lastPullRequestClosedAt, - iso8601.date(from: "2021-06-07T22:47:01Z")) + #expect(res.repository?.lastPullRequestClosedAt == iso8601.date(from: "2021-06-07T22:47:01Z")) } } - func test_fetchMetadata_badRequest() async throws { + @Test func fetchMetadata_badRequest() async throws { await withDependencies { $0.github.token = { "secr3t" } $0.httpClient.post = { @Sendable _, _, _ in .badRequest } @@ -188,17 +182,17 @@ class GithubTests: AppTestCase { do { _ = try await Github.fetchMetadata(owner: "alamofire", repository: "alamofire") - XCTFail("expected error to be thrown") + Issue.record("expected error to be thrown") } catch { guard case Github.Error.requestFailed(.badRequest) = error else { - XCTFail("unexpected error: \(error.localizedDescription)") + Issue.record("unexpected error: \(error.localizedDescription)") return } } } } - func test_fetchMetadata_badData() async throws { + @Test func fetchMetadata_badData() async throws { await withDependencies { $0.github.token = { "secr3t" } $0.httpClient.post = { @Sendable _, _, _ in .ok(body: "bad data") } @@ -206,21 +200,21 @@ class GithubTests: AppTestCase { // MUT do { _ = try await Github.fetchMetadata(owner: "foo", repository: "bar") - XCTFail("expected error to be thrown") + Issue.record("expected error to be thrown") } catch let Github.Error.decodeContentFailed(uri, error) { // validation - XCTAssertEqual(uri, "https://api.github.com/graphql") + #expect(uri == "https://api.github.com/graphql") guard case DecodingError.dataCorrupted = error else { - XCTFail("unexpected error: \(error.localizedDescription)") + Issue.record("unexpected error: \(error.localizedDescription)") return } } catch { - XCTFail("Unexpected error: \(error)") + Issue.record("Unexpected error: \(error)") } } } - func test_fetchMetadata_rateLimiting_429() async throws { + @Test func fetchMetadata_rateLimiting_429() async throws { // Github doesn't actually send a 429 when you hit the rate limit await withDependencies { $0.github.token = { "secr3t" } @@ -229,83 +223,83 @@ class GithubTests: AppTestCase { // MUT do { _ = try await Github.fetchMetadata(owner: "foo", repository: "bar") - XCTFail("expected error to be thrown") + Issue.record("expected error to be thrown") } catch { // validation guard case Github.Error.requestFailed(.tooManyRequests) = error else { - XCTFail("unexpected error: \(error.localizedDescription)") + Issue.record("unexpected error: \(error.localizedDescription)") return } } } } - func test_isRateLimited() throws { + @Test func isRateLimited() throws { do { let res = HTTPClient.Response(status: .forbidden, headers: .init([("X-RateLimit-Remaining", "0")])) - XCTAssertTrue(Github.isRateLimited(res)) + #expect(Github.isRateLimited(res)) } do { let res = HTTPClient.Response(status: .forbidden, headers: .init([("x-ratelimit-remaining", "0")])) - XCTAssertTrue(Github.isRateLimited(res)) + #expect(Github.isRateLimited(res)) } do { let res = HTTPClient.Response(status: .forbidden, headers: .init([("X-RateLimit-Remaining", "1")])) - XCTAssertFalse(Github.isRateLimited(res)) + #expect(!Github.isRateLimited(res)) } do { let res = HTTPClient.Response(status: .forbidden, headers: .init([("unrelated", "0")])) - XCTAssertFalse(Github.isRateLimited(res)) + #expect(!Github.isRateLimited(res)) } do { let res = HTTPClient.Response(status: .ok, headers: .init([("X-RateLimit-Remaining", "0")])) - XCTAssertFalse(Github.isRateLimited(res)) + #expect(!Github.isRateLimited(res)) } } - func test_fetchMetadata_rateLimiting_403() async throws { + @Test func fetchMetadata_rateLimiting_403() async throws { // Github sends a 403 and a rate limit remaining header // X-RateLimit-Limit: 60 // X-RateLimit-Remaining: 56 - // Ensure we record it as a rate limit error and raise a Rollbar item + // Ensure we record it as a rate limit error + let capturingLogger = CapturingLogger() await withDependencies { $0.github.token = { "secr3t" } $0.httpClient.post = { @Sendable _, _, _ in .init(status: .forbidden, headers: ["X-RateLimit-Remaining": "0"]) } + $0.logger.set(to: capturingLogger) } operation: { // MUT do { _ = try await Github.fetchMetadata(owner: "foo", repository: "bar") - XCTFail("expected error to be thrown") + Issue.record("expected error to be thrown") } catch { // validation - logger.logs.withValue { logs in - XCTAssertEqual(logs, [ + capturingLogger.logs.withValue { logs in + #expect(logs == [ .init(level: .critical, message: "rate limited while fetching resource Response") ]) } guard case Github.Error.requestFailed(.tooManyRequests) = error else { - XCTFail("unexpected error: \(error.localizedDescription)") + Issue.record("unexpected error: \(error.localizedDescription)") return } } } } - func test_apiURL() throws { - XCTAssertEqual(Github.apiURL(owner: "foo", repository: "bar", resource: .license), - "https://api.github.com/repos/foo/bar/license") - XCTAssertEqual(Github.apiURL(owner: "foo", repository: "bar", resource: .readme), - "https://api.github.com/repos/foo/bar/readme") + @Test func apiURL() throws { + #expect(Github.apiURL(owner: "foo", repository: "bar", resource: .license) == "https://api.github.com/repos/foo/bar/license") + #expect(Github.apiURL(owner: "foo", repository: "bar", resource: .readme) == "https://api.github.com/repos/foo/bar/readme") } - func test_fetchLicense() async throws { + @Test func fetchLicense() async throws { await withDependencies { $0.github.token = { "secr3t" } $0.httpClient.get = { @Sendable _, _ in @@ -316,11 +310,11 @@ class GithubTests: AppTestCase { let res = await Github.fetchLicense(owner: "PSPDFKit", repository: "PSPDFKit-SP") // validate - XCTAssertEqual(res?.htmlUrl, "https://github.com/PSPDFKit/PSPDFKit-SP/blob/master/LICENSE") + #expect(res?.htmlUrl == "https://github.com/PSPDFKit/PSPDFKit-SP/blob/master/LICENSE") } } - func test_fetchLicense_notFound() async throws { + @Test func fetchLicense_notFound() async throws { // https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/761 await withDependencies { $0.github.token = { "secr3t" } @@ -330,11 +324,11 @@ class GithubTests: AppTestCase { let res = await Github.fetchLicense(owner: "foo", repository: "bar") // validate - XCTAssertEqual(res, nil) + #expect(res == nil) } } - func test_fetchReadme() async throws { + @Test func fetchReadme() async throws { let requestCount = QueueIsolated(0) await withDependencies { $0.github.token = { "secr3t" } @@ -349,7 +343,7 @@ class GithubTests: AppTestCase { } return try .ok(jsonEncode: Response(htmlUrl: "readme url")) default: - XCTFail("unexpected accept header") + Issue.record("unexpected accept header") } enum Error: Swift.Error { case unexpectedCodePath } throw Error.unexpectedCodePath @@ -359,10 +353,9 @@ class GithubTests: AppTestCase { let res = await Github.fetchReadme(owner: "foo", repository: "bar") // validate - XCTAssertEqual(requestCount.value, 2) - XCTAssertEqual( - res, - .init(etag: "etag", + #expect(requestCount.value == 2) + #expect( + res == .init(etag: "etag", html: "readme html", htmlUrl: "readme url", imagesToCache: []) @@ -370,7 +363,7 @@ class GithubTests: AppTestCase { } } - func test_fetchReadme_notFound() async throws { + @Test func fetchReadme_notFound() async throws { await withDependencies { $0.github.token = { "secr3t" } $0.httpClient.get = { @Sendable _, headers in .notFound } @@ -379,11 +372,11 @@ class GithubTests: AppTestCase { let res = await Github.fetchReadme(owner: "foo", repository: "bar") // validate - XCTAssertEqual(res, nil) + #expect(res == nil) } } - func test_extractImagesRequiringCaching() async throws { + @Test func extractImagesRequiringCaching() async throws { try withDependencies { $0.environment.awsReadmeBucket = { "awsReadmeBucket" } } operation: { @@ -403,7 +396,7 @@ class GithubTests: AppTestCase { // MUT let images = Github.replaceImagesRequiringCaching(owner: "owner", repository: "repo", readme: &readme) - XCTAssertEqual(images, [ + #expect(images == [ .init(originalUrl: "https://private-user-images.githubusercontent.com/with-jwt.jpg?jwt=some-jwt", s3Key: S3Store.Key.init(bucket: "awsReadmeBucket", path: "owner/repo/with-jwt.jpg")) ]) @@ -411,7 +404,7 @@ class GithubTests: AppTestCase { let document = try SwiftSoup.parse(readme) let imageElements = try document.select("img").array() - XCTAssertEqual(try imageElements.map { try $0.attr("src") }, [ + #expect(try imageElements.map { try $0.attr("src") } == [ "https://awsReadmeBucket.s3.us-east-2.amazonaws.com/owner/repo/with-jwt.jpg", "https://private-user-images.githubusercontent.com/without-jwt.jpg", "https://raw.githubusercontent.com/raw-image.png", @@ -419,14 +412,14 @@ class GithubTests: AppTestCase { "https://example.com/other-domain.jpg" ]) - XCTAssertEqual(try imageElements.map { try $0.attr("data-original-src") }, [ + #expect(try imageElements.map { try $0.attr("data-original-src") } == [ "https://private-user-images.githubusercontent.com/with-jwt.jpg?jwt=some-jwt", "", "", "", "" // This attribute only gets added to images that will be cached. ]) } } - func test_extractImagesRequiringCaching_noUnnecessaryChanges() async throws { + @Test func extractImagesRequiringCaching_noUnnecessaryChanges() async throws { withDependencies { $0.environment.awsReadmeBucket = { "awsReadmeBucket" } } operation: { @@ -447,12 +440,12 @@ class GithubTests: AppTestCase { let images = Github.replaceImagesRequiringCaching(owner: "owner", repository: "repo", readme: &readme) // Checks - XCTAssertEqual(originalReadme, readme) - XCTAssertEqual(images, []) + #expect(originalReadme == readme) + #expect(images == []) } } - func test_Readme_containsSPIBadge() throws { + @Test func Readme_containsSPIBadge() throws { do { let html = """

@@ -460,11 +453,11 @@ class GithubTests: AppTestCase {

🏷 SemanticVersion

""" let readme = Github.Readme(html: html, htmlUrl: "url", imagesToCache: []) - XCTAssertTrue(readme.containsSPIBadge()) + #expect(readme.containsSPIBadge()) } do { let readme = Github.Readme(html: "some html", htmlUrl: "url", imagesToCache: []) - XCTAssertFalse(readme.containsSPIBadge()) + #expect(!readme.containsSPIBadge()) } } diff --git a/Tests/AppTests/GitlabBuilderTests.swift b/Tests/AppTests/GitlabBuilderTests.swift index f45a08ea5..6ac4f0245 100644 --- a/Tests/AppTests/GitlabBuilderTests.swift +++ b/Tests/AppTests/GitlabBuilderTests.swift @@ -12,29 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -import XCTest - @testable import App import Dependencies +import Testing import Vapor -class GitlabBuilderTests: AppTestCase { +@Suite struct GitlabBuilderTests { - func test_SwiftVersion_rendering() throws { - XCTAssertEqual("\(SwiftVersion.v4)", "6.0.0") - XCTAssertEqual(SwiftVersion.v4.description(droppingZeroes: .none), "6.0.0") - XCTAssertEqual(SwiftVersion.v4.description(droppingZeroes: .patch), "6.0") - XCTAssertEqual(SwiftVersion.v4.description(droppingZeroes: .all), "6") + @Test func SwiftVersion_rendering() throws { + #expect("\(SwiftVersion.v4)" == "6.0.0") + #expect(SwiftVersion.v4.description(droppingZeroes: .none) == "6.0.0") + #expect(SwiftVersion.v4.description(droppingZeroes: .patch) == "6.0") + #expect(SwiftVersion.v4.description(droppingZeroes: .all) == "6") } - func test_variables_encoding() async throws { + @Test func variables_encoding() async throws { // Ensure the POST variables are encoded correctly // setup - let app = try await setup(.testing) - - try await App.run { + try await withApp { app in let req = Request(application: app, on: app.eventLoopGroup.next()) let dto = Gitlab.Builder.PostDTO(token: "token", ref: "ref", @@ -46,14 +43,11 @@ class GitlabBuilderTests: AppTestCase { // validate // Gitlab accepts both `variables[FOO]=bar` and `variables%5BFOO%5D=bar` for the [] encoding. // Since Vapor 4.92.1 this is now encoded as `variables%5BFOO%5D=bar`. - XCTAssertEqual(req.url.query?.split(separator: "&").sorted(), - ["ref=ref", "token=token", "variables%5BFOO%5D=bar"]) - } defer: { - try await app.asyncShutdown() + #expect(req.url.query?.split(separator: "&").sorted() == ["ref=ref", "token=token", "variables%5BFOO%5D=bar"]) } } - func test_triggerBuild() async throws { + @Test func triggerBuild() async throws { let buildId = UUID.id0 let versionId = UUID.id1 let called = QueueIsolated(false) @@ -65,11 +59,11 @@ class GitlabBuilderTests: AppTestCase { $0.environment.siteURL = { "http://example.com" } $0.httpClient.post = { @Sendable _, _, body in called.setValue(true) - let body = try XCTUnwrap(body) + let body = try #require(body) // validate - XCTAssertEqual( - try? URLEncodedFormDecoder().decode(Gitlab.Builder.PostDTO.self, from: body), - Gitlab.Builder.PostDTO( + #expect( + (try? URLEncodedFormDecoder().decode(Gitlab.Builder.PostDTO.self, from: body)) + == Gitlab.Builder.PostDTO( token: "pipeline token", ref: "main", variables: [ @@ -83,7 +77,8 @@ class GitlabBuilderTests: AppTestCase { "SWIFT_VERSION": "5.2", "TIMEOUT": "10m", "VERSION_ID": versionId.uuidString, - ]) + ] + ) ) return try .created(jsonEncode: Gitlab.Builder.Response(webUrl: "http://web_url")) } @@ -96,11 +91,11 @@ class GitlabBuilderTests: AppTestCase { reference: .tag(.init(1, 2, 3)), swiftVersion: .init(5, 2, 4), versionID: versionId) - XCTAssertTrue(called.value) + #expect(called.value) } } - func test_issue_588() async throws { + @Test func issue_588() async throws { let called = QueueIsolated(false) try await withDependencies { $0.environment.awsDocsBucket = { "docs-bucket" } @@ -110,11 +105,11 @@ class GitlabBuilderTests: AppTestCase { $0.environment.siteURL = { "http://example.com" } $0.httpClient.post = { @Sendable _, _, body in called.setValue(true) - let body = try XCTUnwrap(body) + let body = try #require(body) // validate let swiftVersion = (try? URLEncodedFormDecoder().decode(Gitlab.Builder.PostDTO.self, from: body)) .flatMap { $0.variables["SWIFT_VERSION"] } - XCTAssertEqual(swiftVersion, "6.0") + #expect(swiftVersion == "6.0") return try .created(jsonEncode: Gitlab.Builder.Response(webUrl: "http://web_url")) } } operation: { @@ -126,18 +121,17 @@ class GitlabBuilderTests: AppTestCase { reference: .tag(.init(1, 2, 3)), swiftVersion: .v6_0, versionID: .id1) - XCTAssertTrue(called.value) + #expect(called.value) } } - func test_getStatusCount() async throws { + @Test func getStatusCount() async throws { let page = QueueIsolated(1) try await withDependencies { $0.environment.gitlabApiToken = { "api token" } $0.httpClient.get = { @Sendable url, _ in - XCTAssertEqual( - url, - "https://gitlab.com/api/v4/projects/19564054/pipelines?status=pending&page=\(page.value)&per_page=20" + #expect( + url == "https://gitlab.com/api/v4/projects/19564054/pipelines?status=pending&page=\(page.value)&per_page=20" ) let pending = #"{"id": 1, "status": "pending"}"# defer { page.increment() } @@ -145,7 +139,7 @@ class GitlabBuilderTests: AppTestCase { case 1: 20 case 2: 10 default: - XCTFail("unexpected page: \(page)") + Issue.record("unexpected page: \(page)") throw Abort(.badRequest) } let list = Array(repeating: pending, count: elementsPerPage).joined(separator: ", ") @@ -155,21 +149,22 @@ class GitlabBuilderTests: AppTestCase { let res = try await Gitlab.Builder.getStatusCount(status: .pending, pageSize: 20, maxPageCount: 3) - XCTAssertEqual(res, 30) + #expect(res == 30) } } } -class LiveGitlabBuilderTests: AppTestCase { +@Suite + - func test_triggerBuild_live() async throws { - try XCTSkipIf( - true, - "This is a live trigger test for end-to-end testing of pre-release builder versions" - ) +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" } diff --git a/Tests/AppTests/Helpers/TestSupport.swift b/Tests/AppTests/Helpers/TestSupport.swift index 224ad6d6c..4b5960d80 100644 --- a/Tests/AppTests/Helpers/TestSupport.swift +++ b/Tests/AppTests/Helpers/TestSupport.swift @@ -29,11 +29,8 @@ func withApp(_ setup: (Application) async throws -> Void = { _ in }, return try await run { try await setup(app) try await withDependencies(updateValuesForOperation) { - let logger = logHandler.map { handler in Logger(label: "test", factory: { _ in handler }) } try await withDependencies { - if let logger { - $0.logger.set(to: logger) - } + $0.logger.set(to: logHandler) } operation: { try await test(app) }