@@ -32,4 +32,42 @@ final class AppTests: XCTestCase {
32
32
XCTAssertEqual ( res. status, HTTPStatus . ok)
33
33
}
34
34
}
35
+
36
+ func test_routesAreMounted( ) throws {
37
+ let app = try testApp ( )
38
+ defer { app. shutdown ( ) }
39
+
40
+ app. middleware. use ( JSONAPIErrorMiddleware ( ) )
41
+
42
+ try addRoutes ( app, hobbled: true )
43
+
44
+ let expectedRoutes = [
45
+ [ " POST " , " openapi_sources " ] ,
46
+ [ " GET " , " openapi_sources " ] ,
47
+ [ " GET " , " openapi_sources " , " :id " ] ,
48
+
49
+ [ " POST " , " api_test_properties " ] ,
50
+ [ " GET " , " api_test_properties " ] ,
51
+ [ " GET " , " api_test_properties " , " :id " ] ,
52
+
53
+ [ " POST " , " api_tests " ] ,
54
+ [ " GET " , " api_tests " ] ,
55
+ [ " GET " , " api_tests " , " :id " ] ,
56
+ [ " GET " , " api_tests " , " :id " , " files " ] ,
57
+ [ " GET " , " api_tests " , " :id " , " logs " ] ,
58
+
59
+ [ " GET " , " api_test_messages " , " :id " ] ,
60
+
61
+ [ " GET " , " watch " ] ,
62
+
63
+ [ " GET " , " docs " ]
64
+ ]
65
+
66
+ for path in expectedRoutes {
67
+ XCTAssert ( app. routes. all. contains { route in [ route. method. rawValue] + route. path. map ( \. description) == path } )
68
+ }
69
+
70
+ // protect against adding routes without adding them to the test
71
+ XCTAssertEqual ( app. routes. all. count, expectedRoutes. count)
72
+ }
35
73
}
0 commit comments