mirror of
https://github.com/wneessen/go-hibp.git
synced 2024-11-22 21:00:51 +01:00
Fix code smell in WithUserAgent() option detected by SonarQube
This commit is contained in:
parent
6a561b0f7a
commit
842cc122a5
2 changed files with 7 additions and 1 deletions
2
hibp.go
2
hibp.go
|
@ -95,7 +95,7 @@ func WithPwnedPadding() Option {
|
|||
// WithUserAgent sets a custom user agent string for the HTTP client
|
||||
func WithUserAgent(a string) Option {
|
||||
if a == "" {
|
||||
return func(c *Client) {}
|
||||
return nil
|
||||
}
|
||||
return func(c *Client) {
|
||||
c.ua = a
|
||||
|
|
|
@ -65,4 +65,10 @@ func TestNewWithUserAgent(t *testing.T) {
|
|||
t.Errorf("hibp client custom user agent was not set properly. Expected %s, got: %s",
|
||||
custUA, hc.ua)
|
||||
}
|
||||
|
||||
hc = New(WithUserAgent(""))
|
||||
if hc.ua != DefaultUserAgent {
|
||||
t.Errorf("hibp client custom user agent was not set properly. Expected %s, got: %s",
|
||||
DefaultUserAgent, hc.ua)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue