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