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:
ᴜɴᴋɴᴡᴏɴ
2020-04-14 09:41:54 +08:00
committed by GitHub
parent 659acd48b1
commit cb439a126a
19 changed files with 427 additions and 167 deletions

View File

@@ -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
}
}