From 2930023c01947d404478b1121c7b0667b6052033 Mon Sep 17 00:00:00 2001 From: Jens Breitbart Date: Sat, 16 Apr 2016 18:06:31 +0200 Subject: [PATCH] Added first ratelimit test. --- ratelimit_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 ratelimit_test.go diff --git a/ratelimit_test.go b/ratelimit_test.go new file mode 100644 index 0000000..6f4a700 --- /dev/null +++ b/ratelimit_test.go @@ -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.") + } +}