Skip to content

Commit

Permalink
Added first ratelimit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreitbart committed Apr 16, 2016
1 parent 2d0f568 commit 2930023
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ratelimit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package imgur

import (
"net/http"
"os"
"testing"

"github.com/koffeinsource/go-klogger"
)

func TestRateLimit(t *testing.T) {
key := os.Getenv("IMGURCLIENTID")
if key == "" {
t.Skip("IMGURCLIENTID environment variable not set.")
}

client := new(Client)
client.HTTPClient = new(http.Client)
client.Log = new(klogger.CLILogger)
client.ImgurClientID = key

rl, err := client.GetRateLimit()

if err != nil {
t.Errorf("GetRateLimit() failed with error: %v", err)
}

if rl.ClientLimit != 12500 || rl.UserLimit != 500 {
t.Error("Client/User limits are wrong. Probably something broken. Or IMGUR changed their limits. Or you are not using a free account for testing. Sorry. No real good way to test this.")
}
}

0 comments on commit 2930023

Please # to comment.