Improved the overall implementation for the DocCMiddleware middleware in the library target.
This commit is contained in:
@@ -296,16 +296,12 @@ private extension DocCMiddlewareTests {
|
||||
) {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let middleware = DocCMiddleware(
|
||||
let middleware = DocCMiddleware<RequestContextMock, LocalFileSystem>(
|
||||
configuration: configuration,
|
||||
logger: logger
|
||||
)
|
||||
|
||||
// THEN
|
||||
#expect(middleware.configuration.folderRoot == configuration.folderRoot)
|
||||
#expect(middleware.configuration.uriRoot == configuration.uriRoot)
|
||||
#expect(middleware.configuration.threadPool === configuration.threadPool)
|
||||
|
||||
#expect(middleware.logger.label == logger.label)
|
||||
#expect(middleware.logger.logLevel == logger.logLevel)
|
||||
#expect(middleware.logger.metadataProvider == nil)
|
||||
@@ -325,17 +321,13 @@ private extension DocCMiddlewareTests {
|
||||
) {
|
||||
// GIVEN
|
||||
// WHEN
|
||||
let middleware = DocCMiddleware(
|
||||
let middleware = DocCMiddleware<RequestContextMock, FileSystemProvider>(
|
||||
configuration: configuration,
|
||||
fileProvider: fileProvider,
|
||||
logger: logger
|
||||
)
|
||||
|
||||
// THEN
|
||||
#expect(middleware.configuration.folderRoot == configuration.folderRoot)
|
||||
#expect(middleware.configuration.uriRoot == configuration.uriRoot)
|
||||
#expect(middleware.configuration.threadPool === configuration.threadPool)
|
||||
|
||||
#expect(middleware.logger.label == logger.label)
|
||||
#expect(middleware.logger.logLevel == logger.logLevel)
|
||||
#expect(middleware.logger.metadataProvider == nil)
|
||||
@@ -363,13 +355,13 @@ private extension DocCMiddlewareTests {
|
||||
handler: logHandler
|
||||
)
|
||||
|
||||
let context: any RequestContext = RequestContextMock(logger: logger)
|
||||
let context: RequestContextMock = .init(logger: logger)
|
||||
let request: Request = .test(
|
||||
method: .get,
|
||||
path: uriPath
|
||||
)
|
||||
|
||||
let middleware = DocCMiddleware(
|
||||
let middleware = DocCMiddleware<RequestContextMock, FileProviderMock>(
|
||||
configuration: .init(
|
||||
uriRoot: .Sample.uriRoot,
|
||||
folderRoot: .Sample.uriFolder
|
||||
@@ -455,7 +447,7 @@ private extension DocCMiddlewareTests {
|
||||
path: uriPath
|
||||
)
|
||||
|
||||
let middleware = DocCMiddleware(
|
||||
let middleware = DocCMiddleware<RequestContextMock, FileProviderMock>(
|
||||
configuration: .init(
|
||||
uriRoot: .Sample.uriRoot,
|
||||
folderRoot: .Sample.uriFolder
|
||||
@@ -476,7 +468,7 @@ private extension DocCMiddlewareTests {
|
||||
.contentLength: (statusCode == .ok ? "36" : "0")
|
||||
])
|
||||
|
||||
let contentLength = #require(result.body.contentLength)
|
||||
let contentLength = try #require(result.body.contentLength)
|
||||
|
||||
if statusCode == .ok {
|
||||
#expect(contentLength > 0)
|
||||
@@ -553,7 +545,12 @@ private extension DocCMiddlewareTests {
|
||||
|
||||
private extension Input {
|
||||
/// A list of relative URI paths to match against the URI path redirections done by the middleware.
|
||||
static let redirectURIPaths: [String] = [.empty, .Path.forwardSlash, "/documentation", "/tutorials"]
|
||||
static let redirectURIPaths: [String] = [
|
||||
.empty,
|
||||
.Path.forwardSlash,
|
||||
"/documentation",
|
||||
"/tutorials"
|
||||
]
|
||||
/// A list of relative URI paths to match against the URI path servings done by the middleware.
|
||||
static let serveURIPaths: [String] = [
|
||||
"/documentation/",
|
||||
@@ -575,22 +572,27 @@ private extension Input {
|
||||
|
||||
private extension Output {
|
||||
/// A list of expected relative URI path redirections outputs coming out of the URI path redirections done by the middleware.
|
||||
static let redirectURIPaths: [String] = [.Path.forwardSlash, "/documentation", "/documentation/", "/tutorials/"]
|
||||
static let redirectURIPaths: [String] = [
|
||||
"/documentation",
|
||||
"/documentation",
|
||||
"/documentation/",
|
||||
"/tutorials/"
|
||||
]
|
||||
/// A list of expected relative file URI paths of the logged messages coming out of the URI path servings done by the middleware.
|
||||
static let serveURIFilePaths: [String] = [
|
||||
"/SomeDocument.doccarchive/documentation/somedocument/index.html",
|
||||
"/SomeDocument.doccarchive/tutorials/somedocument/index.html",
|
||||
"/SomeDocument.doccarchive/data/documentation/somedocument.json",
|
||||
"/SomeDocument.doccarchive/SomeDocument/favicon.ico",
|
||||
"/SomeDocument.doccarchive/SomeDocument/favicon.svg",
|
||||
"/SomeDocument.doccarchive/SomeDocument/theme-settings.json",
|
||||
"/SomeDocument.doccarchive/SomeDocument/css/file.css",
|
||||
"/SomeDocument.doccarchive/SomeDocument/data/data.bin",
|
||||
"/SomeDocument.doccarchive/SomeDocument/downloads/file.txt",
|
||||
"/SomeDocument.doccarchive/SomeDocument/images/image.png",
|
||||
"/SomeDocument.doccarchive/SomeDocument/img/image.jpg",
|
||||
"/SomeDocument.doccarchive/SomeDocument/index/file",
|
||||
"/SomeDocument.doccarchive/SomeDocument/js/file.js",
|
||||
"/SomeDocument.doccarchive/SomeDocument/videos/video.mp4"
|
||||
"/SomeDocument.doccarchive/favicon.ico",
|
||||
"/SomeDocument.doccarchive/favicon.svg",
|
||||
"/SomeDocument.doccarchive/theme-settings.json",
|
||||
"/SomeDocument.doccarchive/css/file.css",
|
||||
"/SomeDocument.doccarchive/data/data.bin",
|
||||
"/SomeDocument.doccarchive/downloads/file.txt",
|
||||
"/SomeDocument.doccarchive/images/image.png",
|
||||
"/SomeDocument.doccarchive/img/image.jpg",
|
||||
"/SomeDocument.doccarchive/index/file",
|
||||
"/SomeDocument.doccarchive/js/file.js",
|
||||
"/SomeDocument.doccarchive/videos/video.mp4"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user