Skip to content

Commit 0458584

Browse files
committed
test(password): enhance password unit tests with new password creation validation
- Added tests to validate the creation of a new password object using the default salt. - Ensured that the new password object is not nil and has a non-empty salt. - Verified that the new password correctly matches the original password value and is not empty.
1 parent e2f762a commit 0458584

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

password/pass_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,11 @@ func TestNew_DefaultSalt(t *testing.T) {
1616
assert.NotEmpty(t, passwordObj.Salt())
1717
assert.True(t, passwordObj.Equal(passwordObj.Value()))
1818
assert.False(t, passwordObj.Equal(""))
19+
20+
newPwd, err := password.New(pwd, passwordObj.Salt())
21+
assert.Nil(t, err)
22+
assert.NotNil(t, newPwd)
23+
assert.NotEmpty(t, newPwd.Salt())
24+
assert.True(t, newPwd.Equal(passwordObj.Value()))
25+
assert.False(t, newPwd.Equal(""))
1926
}

0 commit comments

Comments
 (0)