diff --git a/sync/gate_test.go b/sync/gate_test.go index da41a73..747e9d6 100644 --- a/sync/gate_test.go +++ b/sync/gate_test.go @@ -1,6 +1,7 @@ package usync import "time" +import "errors" import "testing" func TestGate(test *testing.T) { @@ -50,3 +51,13 @@ func TestGateCloseEarly(test *testing.T) { test.Fatal("timed out waiting for sender goroutine to stop") } } + +func TestGateCloseIdempotent(test *testing.T) { + gate := NewGate[int]() + err := gate.Close() + if err != nil { test.Fatal(err) } + err = gate.Close() + if !errors.Is(err, ErrAlreadyClosed) { + test.Fatal("wrong error: ", err) + } +}