aboutsummaryrefslogtreecommitdiff
path: root/stmutil/context_test.go
diff options
context:
space:
mode:
authorMatt Joiner <anacrolix@gmail.com>2019-11-05 18:57:25 +1100
committerMatt Joiner <anacrolix@gmail.com>2019-11-05 18:57:25 +1100
commite8c572c45b4d028cfc0c608699434bc8e8808c67 (patch)
tree42d166c056f215a6b065fe4fca6a976aff3b4825 /stmutil/context_test.go
parentAdd failed commits profiling (diff)
downloadstm-e8c572c45b4d028cfc0c608699434bc8e8808c67.tar.gz
stm-e8c572c45b4d028cfc0c608699434bc8e8808c67.tar.xz
Cache ContextDoneVars
Note that nothing currently flushes them. Could probably flush them when they're done, and the early return will take care of the rest.
Diffstat (limited to 'stmutil/context_test.go')
-rw-r--r--stmutil/context_test.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/stmutil/context_test.go b/stmutil/context_test.go
new file mode 100644
index 0000000..0a6b7c0
--- /dev/null
+++ b/stmutil/context_test.go
@@ -0,0 +1,20 @@
+package stmutil
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestContextEquality(t *testing.T) {
+ ctx := context.Background()
+ assert.True(t, ctx == context.Background())
+ childCtx, cancel := context.WithCancel(ctx)
+ assert.True(t, childCtx != ctx)
+ assert.True(t, childCtx != ctx)
+ assert.Equal(t, context.Background(), ctx)
+ cancel()
+ assert.Equal(t, context.Background(), ctx)
+ assert.NotEqual(t, ctx, childCtx)
+}