spirit icon indicating copy to clipboard operation
spirit copied to clipboard

Road to 100% Coverage

Open lukewhrit opened this issue 3 years ago • 2 comments

Description

If we ever want Spacebin to be stable and suited for use in production environments, we must ensure builds are reproducible and that code issues are caught before they are pushed to a release. To this end, we want to create unit tests for every aspect of the program that checks and ensures everything works according to the specifications.

This issue contains a list of every part of Spacebin that should be tested, and whether it's currently being tested or not. Our top priority should be the Server (API) functions. We want to make sure that API routes are returning what we want.

Progress

  • [X] Config
    • [X] Loading config
  • [ ] Server
    • [x] Config route
    • [ ] Create document
      • [ ] Creating a document and getting the correct Document in response
      • [ ] Creating a document and getting sent to the correct webpage
      • [ ] Failing when given bad content
    • [ ] Fetch document
      • [X] Fetching a document
      • [ ] Fetching a document and getting plain-text
      • [ ] Failing on a non-existent document
      • [ ] Failing on a bad id
    • [ ] Core server
      • [x] Creating a server instance
      • [ ] Mounting middleware
      • [x] Registering security headers
      • [x] Mounting static content
      • [ ] Mounting route handlers
  • [x] Utility functions
    • [X] Ratelimiter string parser
      • [X] Fail on invalid strings (i.e. too many parts, invalid number syntax, number out of range)
      • [X] Pass on valid strings
    • [X] ID generation
      • [X] Generating a phrase
      • [X] Generating a key
    • [x] Helpers
      • [X] Count lines of a document and convert that into HTML line identifiers
      • [X] Validate body of a create document request
      • [x] Identifying and decoding POST request bodies
      • [x] Writing JSON objects to an HTTP response writer
      • [x] Writing Errors to an HTTP response writer

lukewhrit avatar Sep 08 '20 17:09 lukewhrit

Update: We've partially implemented testing with the help of @GreatGodApollo. See document/routes_test.go. There's still a lot more to do but it's a start.

lukewhrit avatar Sep 12 '20 05:09 lukewhrit

Stale issue message

github-actions[bot] avatar Nov 29 '20 00:11 github-actions[bot]

We need a library for mock database interactions in order to implement tests for Fetch/Create endpoints

lukewhrit avatar Aug 06 '23 04:08 lukewhrit

We need to configure codecov to ignore the httplog middleware (util/logger.go) and perhaps the config route handler. As far as I can tell that code cannot error under any reasonable circumstance since it's being encoded from a strictly typed struct.

lukewhrit avatar Aug 09 '23 05:08 lukewhrit