sync: Test idempotency of Gate.Close
This commit is contained in:
parent
b5044de085
commit
2173550bc8
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user