dcrdata
dcrdata copied to clipboard
Continue test coverage for explorer routes and middleware
PR https://github.com/decred/dcrdata/pull/887 refactored several packages to facilitate testing of the explorerUI page handlers, and added a test of StatusPage in the new explorer/explorerroutes_test.go. Tests should be crafted for all of the page handlers to ensure their behaviour is correct given various inputs.
Inputs to test:
- URL query parameters (e.g.
/path?param1=val1¶m2=val2) - URL path parameters (e.g.
/path/{param})
Outputs:
- HTTP status codes
- Response headers
- Body content
The middleware may be tested separately from the http handlers, and vice versa.
Note that in the new explorerroutes_test.go, explorerUI instances are created using stubbed out database backends, where for each the output of each called backend function is hard coded so a live database is not required to test the http handlers.