Debian Codegraph @

api/v1/lib/extras/latch/latch_test.go

raw symbols SCIP
1 package latch_test
2
3 import (
4 "testing"
5
6 . "github.com/mesos/mesos-go/api/v1/lib/extras/latch"
7 )
8
9 func TestInterface(t *testing.T) {
10 l := New()
11 if l == nil {
12 t.Fatalf("expected a valid latch, not nil")
13 }
14 if l.Closed() {
15 t.Fatalf("expected new latch to be non-closed")
16 }
17 select {
18 case <-l.Done():
19 t.Fatalf("Done chan unexpectedly closed for a new latch")
20 default:
21 }
22 for i := 0; i < 2; i++ {
23 l.Close() // multiple calls to close should not panic
24 }
25 if !l.Closed() {
26 t.Fatalf("expected closed latch")
27 }
28 select {
29 case <-l.Done():
30 default:
31 t.Fatalf("Done chan unexpectedly non-closed for a closed latch")
32 }
33 }