sync: Test idempotency of Gate.Close

This commit is contained in:
Sasha Koshka 2025-01-25 19:58:51 -05:00
parent b5044de085
commit 2173550bc8

View File

@ -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)
}
}