From edf780328a232e434ff181e67d716133a783af3d Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 15 Apr 2020 13:10:39 +0200 Subject: [PATCH] Test nil values --- server/limiter_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/server/limiter_test.go b/server/limiter_test.go index 7f979548f..98737074b 100644 --- a/server/limiter_test.go +++ b/server/limiter_test.go @@ -41,6 +41,15 @@ func TestLimiter(t *testing.T) { if o := <-out; o.Key != p.Key || o.Val != p.Val { t.Errorf("unexpected param %v", o) } + + // allow nils + clck.Add(2 * l.interval) + p.Val = nil + in <- p + + if o := <-out; o.Key != p.Key || o.Val != p.Val { + t.Errorf("unexpected param %v", o) + } } func TestDeduplicator(t *testing.T) { @@ -65,6 +74,14 @@ func TestDeduplicator(t *testing.T) { t.Errorf("unexpected param %v", o) } + // allow nils + p = core.Param{Key: "k", Val: nil} + in <- p + + if o := <-out; o.Key != p.Key || o.Val != p.Val { + t.Errorf("unexpected param %v", o) + } + p = core.Param{Key: "filtered", Val: 3} in <- p @@ -96,4 +113,12 @@ func TestDeduplicator(t *testing.T) { if o := <-out; o.Key != p.Key || o.Val != p.Val { t.Errorf("unexpected param %v", o) } + + // allow nils + p = core.Param{Key: "filtered", Val: nil} + in <- p + + if o := <-out; o.Key != p.Key || o.Val != p.Val { + t.Errorf("unexpected param %v", o) + } }