Expand config test coverage

This commit is contained in:
Adrian Gallagher
2019-09-16 17:15:38 +10:00
parent 870fd6f4f3
commit 09d642c381
5 changed files with 149 additions and 70 deletions

View File

@@ -90,8 +90,8 @@ func NewRateLimit(d time.Duration, rate int) *RateLimit {
return &RateLimit{Duration: d, Rate: rate}
}
// ToString returns the rate limiter in string notation
func (r *RateLimit) ToString() string {
// String returns the rate limiter in string notation
func (r *RateLimit) String() string {
return fmt.Sprintf("Rate limiter set to %d requests per %v", r.Rate, r.Duration)
}

View File

@@ -66,15 +66,15 @@ func TestIsRateLimited(t *testing.T) {
r := New("bitfinex", NewRateLimit(time.Second*10, 5), NewRateLimit(time.Second*20, 100), new(http.Client))
r.StartCycle()
if r.AuthLimit.ToString() != "Rate limiter set to 5 requests per 10s" {
if r.AuthLimit.String() != "Rate limiter set to 5 requests per 10s" {
t.Fatal("unexcpted values")
}
if r.UnauthLimit.ToString() != "Rate limiter set to 100 requests per 20s" {
if r.UnauthLimit.String() != "Rate limiter set to 100 requests per 20s" {
t.Fatal("unexpected values")
}
if r.AuthLimit.ToString() != "Rate limiter set to 5 requests per 10s" {
if r.AuthLimit.String() != "Rate limiter set to 5 requests per 10s" {
t.Fatal("unexcpted values")
}