File: latch_test.go

package info (click to toggle)
golang-github-mesos-mesos-go 0.0.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 11,724 kB
  • sloc: makefile: 163
file content (33 lines) | stat: -rw-r--r-- 633 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package latch_test

import (
	"testing"

	. "github.com/mesos/mesos-go/api/v1/lib/extras/latch"
)

func TestInterface(t *testing.T) {
	l := New()
	if l == nil {
		t.Fatalf("expected a valid latch, not nil")
	}
	if l.Closed() {
		t.Fatalf("expected new latch to be non-closed")
	}
	select {
	case <-l.Done():
		t.Fatalf("Done chan unexpectedly closed for a new latch")
	default:
	}
	for i := 0; i < 2; i++ {
		l.Close() // multiple calls to close should not panic
	}
	if !l.Closed() {
		t.Fatalf("expected closed latch")
	}
	select {
	case <-l.Done():
	default:
		t.Fatalf("Done chan unexpectedly non-closed for a closed latch")
	}
}