diff --git a/Test/Sources/Cases/Internal/Middlewares/DoccMiddlewareTests.swift b/Test/Sources/Cases/Internal/Middlewares/DoccMiddlewareTests.swift index 931abd9..d5cedfe 100644 --- a/Test/Sources/Cases/Internal/Middlewares/DoccMiddlewareTests.swift +++ b/Test/Sources/Cases/Internal/Middlewares/DoccMiddlewareTests.swift @@ -1,10 +1,3 @@ -// -// Test.swift -// DocCRepo -// -// Created by Javier Cicchelli on 08/03/2025. -// - import Hummingbird import HummingbirdTesting import Testing diff --git a/Test/Sources/Cases/Public/AppTests.swift b/Test/Sources/Cases/Public/AppTests.swift deleted file mode 100644 index 7622998..0000000 --- a/Test/Sources/Cases/Public/AppTests.swift +++ /dev/null @@ -1,33 +0,0 @@ -import AppLibrary -import Hummingbird -import HummingbirdTesting -import Testing - -struct AppTests { - - // MARK: Properties - - private let arguments = TestArguments() - private let builder = AppBuilder(name: "DocCRepo") - - // MARK: Route tests - - @Test(arguments: ["/"]) - func routes(_ uri: String) async throws { - let app = try await builder(arguments) - - try await app.test(.router) { client in - try await client.execute(uri: uri, method: .get) { response in - #expect(response.status == .ok) - #expect(response.body == .empty) - } - } - } - -} - -// MARK: ByteBuffer+Constants - -private extension ByteBuffer { - static let empty = ByteBuffer(string: "") -} diff --git a/Test/Sources/Cases/Public/Builders/AppBuilderTests.swift b/Test/Sources/Cases/Public/Builders/AppBuilderTests.swift new file mode 100644 index 0000000..641b77b --- /dev/null +++ b/Test/Sources/Cases/Public/Builders/AppBuilderTests.swift @@ -0,0 +1,86 @@ +import AppLibrary +import Hummingbird +import HummingbirdTesting +import Testing + +@Suite("AppBuilder", .tags(.builder)) +struct AppBuilderTests { + + // MARK: Properties + + private let appBuilder = AppBuilder( + appName: "DoxyTest", + archivesFolder: "Resources/Archives/Test" + ) + private let arguments = TestArguments() + + // MARK: Route tests + + @Test(arguments: zip([String].uris, [HTTPResponse.Status].statuses)) + func routes( + uri: String, + expects status: HTTPResponse.Status + ) async throws { + let app = try await appBuilder(arguments) + + try await app.test(.router) { client in + try await client.execute( + uri: uri, + method: .get + ) { response in + #expect(response.status == status) + } + } + } + +} + +// MARK: - Collection+HTTPResponseStatus + +private extension Collection where Element == HTTPResponse.Status { + + // MARK: Computed + + static var statuses: [Element] {[ + .notFound, + .notFound, + .notFound, + .notFound, + .seeOther, + .seeOther, + .notImplemented, + .seeOther, + .seeOther, + .seeOther, + .seeOther, + .notImplemented, + .seeOther, + .seeOther, + ]} + +} + +// MARK: - Collection+String + +private extension Collection where Element == String { + + // MARK: Computed + + static var uris: [Element] {[ + "/", + "/index.html", + "/xxx", + "/archives", + "/archives/SomeArchive", + "/archives/SomeArchive/", + "/archives/SomeArchive/index.html", + "/archives/SomeArchive/documentation", + "/archives/SomeArchive/tutorials", + "/archives/SlothCreator", + "/archives/SlothCreator/", + "/archives/SlothCreator/index.html", + "/archives/SlothCreator/documentation", + "/archives/SlothCreator/tutorials", + ]} + +} diff --git a/Test/Sources/Helpers/Extensions/Tag+Definitions.swift b/Test/Sources/Helpers/Extensions/Tag+Definitions.swift index ec4e135..5948593 100644 --- a/Test/Sources/Helpers/Extensions/Tag+Definitions.swift +++ b/Test/Sources/Helpers/Extensions/Tag+Definitions.swift @@ -4,6 +4,7 @@ extension Tag { // MARK: Constants + @Tag static var builder: Tag @Tag static var enumeration: Tag @Tag static var middleware: Tag @Tag static var provider: Tag