sourcegraph/internal/database/dbstore_db_test.go
Camden Cheek 1252b9a59a
Remove dbtesting package (#28426)
This removes the deprecated dbtesting package. It was only used in ~40 tests, so I just finished it off by converting them all to use dbtest.NewDB(). For the most part, this was just a mechanical rename, but I've marked any additional work needed to do this or fix tests explicitly with comments. There were a few spots that depended on the global behavior of dbtesting.
2021-12-02 08:24:03 -07:00

30 lines
670 B
Go

package database
import (
"testing"
)
func TestPassword(t *testing.T) {
// By default we use fast mocks for our password in tests. This ensures
// our actual implementation is correct.
oldHash := MockHashPassword
oldValid := MockValidPassword
MockHashPassword = nil
MockValidPassword = nil
defer func() {
MockHashPassword = oldHash
MockValidPassword = oldValid
}()
h, err := hashPassword("correct-password")
if err != nil {
t.Fatal(err)
}
if !validPassword(h.String, "correct-password") {
t.Fatal("validPassword should of returned true")
}
if validPassword(h.String, "wrong-password") {
t.Fatal("validPassword should of returned false")
}
}