| 47 | } |
| 48 | |
| 49 | func TestRateLimits(t *testing.T) { |
| 50 | limits, _, err := client.RateLimit.Get(t.Context()) |
| 51 | if err != nil { |
| 52 | t.Fatalf("RateLimits returned error: %v", err) |
| 53 | } |
| 54 | |
| 55 | // do some sanity checks |
| 56 | if limits.Core.Limit == 0 { |
| 57 | t.Error("RateLimits returned 0 core limit") |
| 58 | } |
| 59 | |
| 60 | if limits.Core.Limit < limits.Core.Remaining { |
| 61 | t.Error("Core.Limits is less than Core.Remaining.") |
| 62 | } |
| 63 | |
| 64 | if limits.Core.Reset.Time.Before(time.Now().Add(-1 * time.Minute)) { |
| 65 | t.Error("Core.Reset is more than 1 minute in the past; that doesn't seem right.") |
| 66 | } |
| 67 | } |