dcrdata icon indicating copy to clipboard operation
dcrdata copied to clipboard

Continue test coverage for explorer routes and middleware

Open chappjc opened this issue 7 years ago • 0 comments

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&param2=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.

chappjc avatar Dec 19 '18 22:12 chappjc