From 499c90ccda019fae96ae07caac87c14e31ef7015 Mon Sep 17 00:00:00 2001 From: boyska Date: Thu, 8 Nov 2018 19:51:00 +0100 Subject: [PATCH] test limit --- hub_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hub_test.go b/hub_test.go index 457ddb2..b865910 100644 --- a/hub_test.go +++ b/hub_test.go @@ -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) + } +}