From a50a8603ebe5a1cd2becf1487a6007edaaa9450c Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Tue, 21 Sep 2021 19:47:17 +0200 Subject: [PATCH] Wrong type in Errorf() --- hibp_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hibp_test.go b/hibp_test.go index 698178e..3f25437 100644 --- a/hibp_test.go +++ b/hibp_test.go @@ -1,6 +1,7 @@ package hibp import ( + "os" "testing" "time" ) @@ -38,3 +39,17 @@ func TestNewWithPwnedPadding(t *testing.T) { true, hc.PwnedPassApiOpts.WithPadding) } } + +// TestNewWithApiKey tests the New() function with the API key set +func TestNewWithApiKey(t *testing.T) { + apiKey := os.Getenv("HIBP_API_KEY") + hc := New(WithApiKey(apiKey)) + if hc == nil { + t.Errorf("hibp client creation failed") + return + } + if hc.ak != apiKey { + t.Errorf("hibp client API key was not set properly. Expected %s, got: %s", + apiKey, hc.ak) + } +}