Improved the naming of some test cases for Swift below 6.2 in the tests target.

This commit is contained in:
2025-09-25 01:40:03 +02:00
parent ff56875a24
commit 7a17e83f8c
5 changed files with 22 additions and 20 deletions
@@ -43,7 +43,7 @@ struct LoggerMetadata_HelpersTests {
} }
#else #else
@Test("metadata with HTTP method and status code") @Test("metadata with HTTP method and status code")
func metadataWithMethodAndStatusCode() throws { func metadata_withMethod_andStatusCode() throws {
assertMetadata( assertMetadata(
method: try randomMethod, method: try randomMethod,
statusCode: try randomStatusCode statusCode: try randomStatusCode
@@ -51,7 +51,7 @@ struct LoggerMetadata_HelpersTests {
} }
@Test("metadata with HTTP method, status code and redirection URI path") @Test("metadata with HTTP method, status code and redirection URI path")
func metadataWithMethodStatusCodeAndRedirection() throws { func metadata_withMethod_statusCode_andRedirection() throws {
assertMetadata( assertMetadata(
method: try randomMethod, method: try randomMethod,
statusCode: try randomStatusCode, statusCode: try randomStatusCode,
@@ -52,7 +52,7 @@ struct CheckURIUseCaseTests {
Input.nonEncodedURIs, Input.nonEncodedURIs,
Output.nonEncodedURIs Output.nonEncodedURIs
)) ))
func checkNonEncodedURIs( func check_nonEncodedURIs(
uri uriPath: String, uri uriPath: String,
expects result: String? expects result: String?
) { ) {
@@ -63,7 +63,7 @@ struct CheckURIUseCaseTests {
Input.percentEncodedURIs, Input.percentEncodedURIs,
Output.percentEncodedURIs Output.percentEncodedURIs
)) ))
func checkPercentEncodedURIs( func check_percentEncodedURIs(
uri uriPath: String, uri uriPath: String,
expects result: String? expects result: String?
) { ) {
@@ -54,7 +54,7 @@ struct PrepareURIPathUseCaseTests {
Input.prepareURIPaths, Input.prepareURIPaths,
Output.prepareURIPaths Output.prepareURIPaths
)) ))
func dataWithURIRootNotSuffixedWithForwardSlash( func data_withURIRoot_notSuffixed_withForwardSlash(
uri uriPath: String, uri uriPath: String,
expects result: PrepareURIPathUseCase.PreparedURIPaths? expects result: PrepareURIPathUseCase.PreparedURIPaths?
) throws { ) throws {
@@ -69,7 +69,7 @@ struct PrepareURIPathUseCaseTests {
Input.prepareURIPathsSlashed, Input.prepareURIPathsSlashed,
Output.prepareURIPaths Output.prepareURIPaths
)) ))
func dataWithURIRootSuffixedWithForwardSlash( func data_withURIRoot_suffixed_withForwardSlash(
uri uriPath: String, uri uriPath: String,
expects result: PrepareURIPathUseCase.PreparedURIPaths? expects result: PrepareURIPathUseCase.PreparedURIPaths?
) throws { ) throws {
@@ -10,9 +10,12 @@
// //
// ===----------------------------------------------------------------------=== // ===----------------------------------------------------------------------===
import Hummingbird
import Testing import Testing
import protocol Hummingbird.RequestContext
import struct Hummingbird.HTTPResponse
import struct Hummingbird.Request
import struct Logging.Logger import struct Logging.Logger
@testable import struct DocCMiddleware.RedirectURIUseCase @testable import struct DocCMiddleware.RedirectURIUseCase
@@ -24,7 +27,7 @@ struct RedirectURIUseCaseTests {
#if swift(>=6.2) #if swift(>=6.2)
@Test @Test
func `response when logger expects an event`() async throws { func `response when logging event triggered`() async throws {
try await assertResponse( try await assertResponse(
logLevel: try randomLogLevelWithEvent, logLevel: try randomLogLevelWithEvent,
uriRedirection: .Sample.uriRedirection, uriRedirection: .Sample.uriRedirection,
@@ -33,7 +36,7 @@ struct RedirectURIUseCaseTests {
} }
@Test @Test
func `response when logger does not expects an event`() async throws { func `response when logging event not triggered`() async throws {
try await assertResponse( try await assertResponse(
logLevel: try randomLogLevelWithNoEvent, logLevel: try randomLogLevelWithNoEvent,
uriRedirection: .Sample.uriRedirection, uriRedirection: .Sample.uriRedirection,
@@ -41,8 +44,8 @@ struct RedirectURIUseCaseTests {
) )
} }
#else #else
@Test("response when logger expects an event") @Test("response when logging event triggered")
func responseWhenLoggerExpectsEvent() async throws { func response_whenEventTriggered() async throws {
try await assertResponse( try await assertResponse(
logLevel: try randomLogLevelWithEvent, logLevel: try randomLogLevelWithEvent,
uriRedirection: .uriRedirection, uriRedirection: .uriRedirection,
@@ -50,8 +53,8 @@ struct RedirectURIUseCaseTests {
) )
} }
@Test("response when logger does not expects an event") @Test("response when logging event not triggered")
func responseWhenLogLevel() async throws { func response_whenEventNotTriggered() async throws {
try await assertResponse( try await assertResponse(
logLevel: try randomLogLevelWithNoEvent, logLevel: try randomLogLevelWithNoEvent,
uriRedirection: .uriRedirection, uriRedirection: .uriRedirection,
@@ -68,8 +71,7 @@ private extension RedirectURIUseCaseTests {
// MARK: Functions // MARK: Functions
/// Asserts the response returned by the ``RedirectURIUseCase`` use case based on the given `logLevel` logging level and the `uriRedirection` /// Asserts a response returned by the ``RedirectURIUseCase`` use case.
/// URI path plus the expected status code of the response.
/// - Parameters: /// - Parameters:
/// - logLevel: A representation of the logging level to set in the `Logger` instance. /// - logLevel: A representation of the logging level to set in the `Logger` instance.
/// - uriRedirection: A URI path to use in the redirection. /// - uriRedirection: A URI path to use in the redirection.
@@ -154,11 +156,11 @@ private extension RedirectURIUseCaseTests {
// MARK: Functions // MARK: Functions
/// Checks whether a logging event should be logged or not, based on a given logging level. /// Checks whether a logging event should be logged or not.
/// - Parameter level: A representation of a logging level defined in the `Logger` instance. /// - Parameter logLevel: A representation of a logging level defined in the logger.
/// - Returns: A boolean value that indicates whether a logging event should have been logged or not. /// - Returns: A boolean value that indicates whether a logging event should have been logged or not.
func shouldEventBeLogged(_ logLevel: Logger.Level) -> Bool { func shouldEventBeLogged(_ logLevel: Logger.Level) -> Bool {
[Logger.Level.trace, .debug].contains(logLevel) [Logger.Level.debug, .trace].contains(logLevel)
} }
} }
@@ -45,7 +45,7 @@ struct DocCMiddlewareTests {
} }
#else #else
@Test("initialize with URI and folder paths") @Test("initialize with URI and folder paths")
func initWithURIAndFolderPaths() { func init_withURI_andFolderPaths() {
assertInit(configuration: .init( assertInit(configuration: .init(
uriRoot: "/path/to/documentation", uriRoot: "/path/to/documentation",
folderRoot: "/location/docc/documentation" folderRoot: "/location/docc/documentation"
@@ -53,7 +53,7 @@ struct DocCMiddlewareTests {
} }
@Test("initialize with type that conforms to the FileProvider protocol") @Test("initialize with type that conforms to the FileProvider protocol")
func initWithURIPathAndFileProviderType() { func init_withURI_path_andFileProviderType() {
assertInit( assertInit(
configuration: .init( configuration: .init(
uriRoot: "/path/to/documentation", uriRoot: "/path/to/documentation",