Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package logger_test
import (
"errors"
"fmt"
"testing"
"time"
"fiskerinc.com/modules/logger"
"fiskerinc.com/modules/testhelper"
)
func TestLimiter(t *testing.T) {
err := errors.New("this is a test")
err2 := errors.New("this is a different test")
limiter := logger.NewLogLimiter(time.Millisecond*1, 5)
result := limiter.Check(err.Error())
if !result {
t.Errorf(testhelper.TestErrorTemplate, "check 1", true, result)
}
result = limiter.Check(err2.Error())
if !result {
t.Errorf(testhelper.TestErrorTemplate, "check different error", true, result)
}
for i := 0; i < 6; i++ {
result = limiter.Check(err.Error())
if result {
t.Errorf(testhelper.TestErrorTemplate, fmt.Sprintf("check %d", i+2), false, result)
}
}
time.Sleep(time.Millisecond * 1)
result = limiter.Check(err.Error())
if !result {
t.Errorf(testhelper.TestErrorTemplate, "check expired", true, result)
}
}