docs: document code style and standard testing procedures
While reviewing big-bang/product/packages/bbctl!216 (merged) I noticed that the linters caught a lot of inconsistencies across our unit tests, many of which changes to assertions and expected strings. We should write a document that outlines some basic, standard procedures and test examples that other tests can be based off of. This will be a good entry point to new team members (especially those unfamiliar with Go). The document can also cover basic test fixtures and mocking as used by bbctl
.
Ideas:
- The doc should answer the question "how do I create a new client to interact with x API?" and explain the ClientGetter and dependency injection patterns
- The doc should show how to test the basic functionality of the clients, showing common happy and sad path tests, mocking out HTTP requests, etc.
- The doc should specifically outline when to use
assert
,require.Error/NoError
, and other standards in unit tests - Maybe a section on table-driven tests since those are a little "unique" to Go.
Edited by Daniel Dides