diff --git a/rate_limiter_channel_test.go b/rate_limiter_channel_test.go new file mode 100644 index 0000000..f62586c --- /dev/null +++ b/rate_limiter_channel_test.go @@ -0,0 +1,27 @@ +// Copyright 2019 Yegor Myskin. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package tailor + +import ( + "testing" + "time" +) + +func TestChannelBasedRateLimiterDisallow(t *testing.T) { + l := NewChannelBasedRateLimiter(30) + defer l.Close() + + start := time.Now() + for i := 0; i < 100; i++ { + if !l.Allow() { + t.FailNow() + } + } + dur := time.Since(start) + + if dur < 3333*time.Millisecond || dur > 3500*time.Millisecond { + t.Errorf("expected duration: ~3.33s, actual: %s", dur) + } +} diff --git a/seeker_test.go b/seeker_test.go index aeb31b4..27a7048 100644 --- a/seeker_test.go +++ b/seeker_test.go @@ -1,3 +1,7 @@ +// Copyright 2019 Yegor Myskin. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package tailor import (