File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
TestWebsitePackage/Sources Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments