Skip to content

Commit a8bea25

Browse files
committed
Test for actual error code & type
1 parent dc47b87 commit a8bea25

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Tests/IgniteTesting/Publishing/Site.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ struct SiteTests {
9393

9494
@Test("Site published with a custom ErrorPage and custom content")
9595
func publishingWithCustomErrorPageAndContent() async throws {
96-
let errorPage = TestErrorPage(title: "A different title", description: "A different description")
96+
let expectedError = PageNotFoundError()
97+
98+
let errorPage = TestErrorPage(title: "A different title", description: "A different description") { error in
99+
#expect(error.statusCode == expectedError.statusCode)
100+
}
97101
let site = TestSiteWithErrorPage(errorPage: errorPage)
98102
var publisher = TestSitePublisher(site: site)
99103

Tests/IgniteTesting/TestWebsitePackage/Sources/TestErrorPage.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,30 @@ struct TestErrorPage: ErrorPage {
1313
var title: String = "Test Error Page"
1414
var description: String = "Test Error Page Description"
1515

16+
let errorChecker: (HTTPError) -> Void
17+
18+
init(
19+
title: String = "Test Error Page",
20+
description: String = "Test Error Page Description",
21+
errorChecker: @escaping (HTTPError) -> Void = { _ in }
22+
) {
23+
self.title = title
24+
self.description = description
25+
self.errorChecker = errorChecker
26+
}
27+
1628
var body: some HTML {
29+
ErrorChecker { errorChecker(error) }
1730
EmptyHTML()
1831
}
32+
33+
struct ErrorChecker: HTML {
34+
init(handler: @escaping () -> Void) {
35+
handler()
36+
}
37+
38+
var body: some HTML {
39+
EmptyHTML()
40+
}
41+
}
1942
}

0 commit comments

Comments
 (0)