terraform/vendor/gopkg.in/ns1/ns1-go.v2/rest/client_test.go

31 lines
626 B
Go

package rest
import (
"testing"
"time"
)
func TestRateLimit(t *testing.T) {
r := RateLimit{
Limit: 10,
Remaining: 10,
Period: 10,
}
if r.WaitTime() != time.Second {
t.Error("WaitTime is wrong duration ", r.WaitTime())
}
if r.PercentageLeft() != 100 {
t.Error("PercentLeft != 100")
}
r.Remaining = 5
if r.PercentageLeft() != 50 {
t.Error("PercentLeft != 50")
}
if r.WaitTime() != time.Second {
t.Error("WaitTime is wrong duration ", r.WaitTime())
}
if r.WaitTimeRemaining() != (time.Duration(2) * time.Second) {
t.Error("WaitTimeRemaining is wrong duration ", r.WaitTimeRemaining())
}
}