Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-10-10 14:11:54 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-10-10 14:14:10 +0300
commit4ed219f0ecfc21e01b8a526d2c3ea14f24544882 (patch)
tree4ab64267227b06c364ee8f361f93249c628a7b13
parent9101539d6c5defae17b86b6ee74f5d40ea6edba4 (diff)
STYLE.md: Document argument order of `testing.TB` and `context.Context`pks-testing-argument-order
Document the order of arguments that we use in this project to be `testing.TB` first, `context.Context` second to make this discoverable. While at it also document our use of `t.Helper()`.
-rw-r--r--STYLE.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/STYLE.md b/STYLE.md
index 667973ee5..3b2ee4b79 100644
--- a/STYLE.md
+++ b/STYLE.md
@@ -194,6 +194,19 @@ func TestT_M_suffix() { ... }
func TestT_M_suffixWithMultipleWords() { ... }
```
+### Test helpers
+
+Helper functions for test helpers should be clearly marked with `t.Helper()` so
+that stack traces become more usable. `testing.TB` arguments should always be
+passed as first parameter, followed by `context.Context` if required.
+
+```go
+func testHelper(tb testing.TB, ctx context.Context) {
+ tb.Helper()
+ ...
+}
+```
+
### Table-driven tests
We like table-driven tests ([Table-driven tests using subtests](https://blog.golang.org/subtests#TOC_4.), [Cheney blog post], [Golang wiki]).