-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add more test to increase test coverage
- Loading branch information
Showing
4 changed files
with
37 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package bcrypt_test | ||
|
||
import ( | ||
"github.com/pkg-id/passwd" | ||
"github.com/pkg-id/passwd/bcrypt" | ||
"testing" | ||
) | ||
|
||
func TestBcryptImpl(t *testing.T) { | ||
impls := []passwd.HashComparer{ | ||
bcrypt.MinCost, | ||
bcrypt.DefaultCost, | ||
bcrypt.MinCost, | ||
} | ||
|
||
const plain = "abc123" | ||
|
||
for _, impl := range impls { | ||
hash, err := impl.Hash(plain) | ||
if err != nil { | ||
t.Fatalf("expect no error; got an error: %v", err) | ||
} | ||
|
||
if err := impl.Compare(hash, plain); err != nil { | ||
t.Errorf("expect password is match") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters