Webhooks (#55), more tests (#35) and python examples (#50)

This commit is contained in:
Philipp Heckel 2021-12-15 16:12:40 -05:00
parent 02f8a32b46
commit 534b93e142
13 changed files with 425 additions and 29 deletions

30
util/limit_test.go Normal file
View file

@ -0,0 +1,30 @@
package util
import (
"testing"
)
func TestLimiter_Add(t *testing.T) {
l := NewLimiter(10)
if err := l.Add(5); err != nil {
t.Fatal(err)
}
if err := l.Add(5); err != nil {
t.Fatal(err)
}
if err := l.Add(5); err != ErrLimitReached {
t.Fatalf("expected ErrLimitReached, got %#v", err)
}
}
func TestLimiter_AddSub(t *testing.T) {
l := NewLimiter(10)
l.Add(5)
if l.Value() != 5 {
t.Fatalf("expected value to be %d, got %d", 5, l.Value())
}
l.Sub(2)
if l.Value() != 3 {
t.Fatalf("expected value to be %d, got %d", 3, l.Value())
}
}