From a056d9b54f4904f11e66fb58e3442ac7dfcc24dc Mon Sep 17 00:00:00 2001 From: dravenk Date: Wed, 20 Mar 2019 20:11:39 +0800 Subject: [PATCH] :bug: Fast failed tests --- roundrobin_weighted_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/roundrobin_weighted_test.go b/roundrobin_weighted_test.go index 0f156f4..249fb7e 100644 --- a/roundrobin_weighted_test.go +++ b/roundrobin_weighted_test.go @@ -46,4 +46,19 @@ func TestRRW_Next(t *testing.T) { if results["server1"] != 7000 || results["server2"] != 9000 || results["server3"] != 13000 { t.Error("the algorithm is wrong", results) } + + w.RemoveAll() + w.Add("server1", 0) + w.Add("server2", 0) + + results = make(map[string]int) + + for i := 0; i < 20000; i++ { + s := w.Next().(string) + results[s]++ + } + + if results["server1"] != 10000 || results["server2"] != 10000 { + t.Error("the algorithm is wrong", results) + } }