mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 19:21:50 +00:00
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.
30 lines
670 B
Go
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")
|
|
}
|
|
}
|