From 8b29b608c44ffc8c800c8e92ed72d0b5958800cf Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 22 Sep 2021 15:16:02 +0200 Subject: [PATCH] Skip tests if no API key is given where required --- breach_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/breach_test.go b/breach_test.go index 9bd2139..4e27d37 100644 --- a/breach_test.go +++ b/breach_test.go @@ -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