Skip tests if no API key is given where required

This commit is contained in:
Winni Neessen 2021-09-22 15:16:02 +02:00
parent c33397ed39
commit 8b29b608c4
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -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
@ -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