Browse Source

test limit

boyska 5 years ago
parent
commit
499c90ccda
1 changed files with 17 additions and 0 deletions
  1. 17 0
      hub_test.go

+ 17 - 0
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)
+	}
+}