summaryrefslogtreecommitdiff
path: root/utilities/utilities_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'utilities/utilities_test.go')
-rw-r--r--utilities/utilities_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/utilities/utilities_test.go b/utilities/utilities_test.go
index 3a84d76..aa66f6b 100644
--- a/utilities/utilities_test.go
+++ b/utilities/utilities_test.go
@@ -14,6 +14,7 @@
package utilities
import (
+ "context"
"log"
"sync"
"testing"
@@ -86,3 +87,32 @@ func TestFilenameAppend(t *testing.T) {
t.Fatalf("%s != %s for FilenameAppend.", expected, result)
}
}
+
+func TestWaitWithContext(t *testing.T) {
+ ctxt, canceller := context.WithCancel(context.Background())
+ never_true := func() bool { return false }
+ mu := sync.Mutex{}
+ cond := sync.NewCond(&mu)
+
+ wg := sync.WaitGroup{}
+
+ wg.Add(3)
+
+ go func() {
+ ContextSignaler(ctxt, 500*time.Millisecond, &never_true, cond)
+ wg.Done()
+ }()
+
+ go func() {
+ WaitWithContext(ctxt, &never_true, &mu, cond)
+ wg.Done()
+ }()
+
+ go func() {
+ time.Sleep(2 * time.Second)
+ canceller()
+ wg.Done()
+ }()
+
+ wg.Wait()
+}