aboutsummaryrefslogtreecommitdiff
path: root/src/context/example_test.go
diff options
context:
space:
mode:
authorSameer Ajmani <sameer@google.com>2023-03-29 17:47:50 -0400
committerSameer Ajmani <sameer@golang.org>2023-04-05 17:18:14 +0000
commite7d59ed204bbb0e70fe1898abb1b82fdf7c25a1f (patch)
tree0d3eece7d7fe53dc1aa27ce1c1d52a002c0c7d58 /src/context/example_test.go
parent0d719823af1343f9921ee0293596f09e36ced0e4 (diff)
downloadgo-e7d59ed204bbb0e70fe1898abb1b82fdf7c25a1f.tar.xz
context: clean up test files
Tests in package context cannot depend directly on package testing due to an import cycle. We resolved this by having test functions in package context_test (x_test.go) forward to test functions in package context (context_test.go). This is fragile, since it's easy to add a test to context_test.go and forget to add the forwarding function, and tests written in this way cannot easily use testing package features like t.Run for subtests. It turns out that only four test functions actually use unexported members of package context. This CL moves all except those four to x_test.go and makes them regular tests. It also updates TestCause to use t.Run and t.Parallel to parallelize its test cases. It also adds documentation indicating when tests should be added to each file. Change-Id: Ic60bae32a7a44e07831b5388c9af219d53ba9af3 Reviewed-on: https://go-review.googlesource.com/c/go/+/480375 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Sameer Ajmani <sameer@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/context/example_test.go')
-rw-r--r--src/context/example_test.go2
1 files changed, 0 insertions, 2 deletions
diff --git a/src/context/example_test.go b/src/context/example_test.go
index 7779f5f1b3..8dad0a4220 100644
--- a/src/context/example_test.go
+++ b/src/context/example_test.go
@@ -10,8 +10,6 @@ import (
"time"
)
-const shortDuration = 1 * time.Millisecond // a reasonable duration to block in an example
-
var neverReady = make(chan struct{}) // never closed
// This example demonstrates the use of a cancelable context to prevent a