-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d0f568
commit 2930023
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") | ||
} | ||
} |