mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-08 23:42:53 +01:00
Winni Neessen
c697a8ef8e
The test for HasBeenPwned function in hibp_test.go has been updated to handle errors more effectively. Instead of failing the test directly upon encountering an error, it now logs the error and terminates the current subtest. This improves the test's resilience and makes debugging easier.
32 lines
637 B
Go
32 lines
637 B
Go
// SPDX-FileCopyrightText: 2021-2024 Winni Neessen <wn@neessen.dev>
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package apg
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestHasBeenPwned(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
password string
|
|
want bool
|
|
}{
|
|
{"Pwned PW", "Test123", true},
|
|
{"Secure PW", "Cta8mWYmW7O*j1V!YMTS", false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got, err := HasBeenPwned(tt.password)
|
|
if err != nil {
|
|
t.Logf("HasBeenPwned() failed: %s", err)
|
|
return
|
|
}
|
|
if tt.want != got {
|
|
t.Errorf("HasBeenPwned() failed, wanted: %t, got: %t", tt.want, got)
|
|
}
|
|
})
|
|
}
|
|
}
|