Skip to content

Commit

Permalink
Skip tests if no API key is given where required
Browse files Browse the repository at this point in the history
  • Loading branch information
wneessen committed Sep 22, 2021
1 parent c33397e commit 8b29b60
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions breach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ func TestBreachedAccount(t *testing.T) {
{"opt-out is not breached", "opt-out", false, false},
}

hc := New(WithApiKey(os.Getenv("HIBP_API_KEY")))
apiKey := os.Getenv("HIBP_API_KEY")
if apiKey == "" {
t.SkipNow()
}
hc := New(WithApiKey(apiKey))
if hc == nil {
t.Error("failed to create HIBP client")
return
Expand Down Expand Up @@ -236,7 +240,11 @@ func TestBreachedAccountWithoutTruncate(t *testing.T) {
{"opt-out is not breached", "opt-out", "", "", true},
}

hc := New(WithApiKey(os.Getenv("HIBP_API_KEY")), WithRateLimitNoFail())
apiKey := os.Getenv("HIBP_API_KEY")
if apiKey == "" {
t.SkipNow()
}
hc := New(WithApiKey(apiKey), WithRateLimitNoFail())
if hc == nil {
t.Error("failed to create HIBP client")
return
Expand Down

0 comments on commit 8b29b60

Please sign in to comment.