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) + } +}