spirit
spirit copied to clipboard
Road to 100% Coverage
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
- [X] Ratelimiter string parser
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.
Stale issue message
We need a library for mock database interactions in order to implement tests for Fetch/Create endpoints
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.