fix: mark random string gen as test helper func
This commit is contained in:
parent
3257b19313
commit
2b65bf70d8
@ -77,7 +77,7 @@ func TestIsPasswordCompromised(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("randomly generated", func(t *testing.T) {
|
t.Run("randomly generated", func(t *testing.T) {
|
||||||
randomStr := genRandomString(12)
|
randomStr := genRandomString(t, 12)
|
||||||
compromised, err := isPasswordCompromised(randomStr)
|
compromised, err := isPasswordCompromised(randomStr)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.False(t, compromised)
|
assert.False(t, compromised)
|
||||||
@ -173,7 +173,9 @@ func TestNormalizeUsername(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func genRandomString(length int) string {
|
func genRandomString(t *testing.T, length int) string {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
const charset = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
const charset = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||||
seededRand := rand.New(rand.NewSource(time.Now().UnixNano()))
|
seededRand := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
b := make([]byte, length)
|
b := make([]byte, length)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user