test limit

This commit is contained in:
boyska 2018-11-08 19:51:00 +01:00
parent f31b2fb74f
commit 499c90ccda

View file

@ -67,3 +67,20 @@ func TestOrder(t *testing.T) {
t.Error("wrong last message", r[1])
}
}
func TestLimit(t *testing.T) {
h := NewHub(5)
go h.Run()
for i := 0; i < 10; i++ {
h.LogMessages <- msg("hi")
}
if hubCount(h) != 5 {
t.Error("wrong message number")
}
r := hubToArrayOpt(h, ClientOptions{Nofollow: true, BacklogLength: 3})
if len(r) != 3 {
t.Error("non-limited!", r)
}
}