ingress-nginx-helm/vendor/github.com/eapache/channels/black_hole_test.go
Manuel Alejandro de Brito Fontes 9bcb5b08ea
Use a ring channel to avoid blocking write of events (#2082)
* Use a ring channel to avoid blocking write of events

* Add eapache/channels dependency
2018-02-13 17:46:18 -08:00

26 lines
410 B
Go

package channels
import "testing"
func TestBlackHole(t *testing.T) {
discard := NewBlackHole()
for i := 0; i < 1000; i++ {
discard.In() <- i
}
discard.Close()
if discard.Len() != 1000 {
t.Error("blackhole expected 1000 was", discard.Len())
}
// no asserts here, this is just for the race detector's benefit
ch := NewBlackHole()
go ch.Len()
go ch.Cap()
go func() {
ch.In() <- nil
}()
}