mirror of
https://github.com/gogs/gogs.git
synced 2025-12-24 01:00:00 +01:00
db: add tests for two factors (#6099)
* Rename to TwoFactors.Create * Use GORM to execute queries * TwoFactor.GetByUserID * Add tests * Fix failing tests * Add MD5 tests * Add tests for RandomChars
This commit is contained in:
@@ -41,3 +41,17 @@ func TestToUpperFirst(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRandomChars(t *testing.T) {
|
||||
cache := make(map[string]bool)
|
||||
for i := 0; i < 100; i++ {
|
||||
chars, err := RandomChars(10)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cache[chars] {
|
||||
t.Fatalf("Duplicated chars %q", chars)
|
||||
}
|
||||
cache[chars] = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user