chore(auth): finalize test of new structure
This commit is contained in:
12
db/auth.go
12
db/auth.go
@@ -38,19 +38,19 @@ func NewUser(id uuid.UUID, email string, emailVerified bool, emailVerifiedAt tim
|
||||
}
|
||||
}
|
||||
|
||||
type Auth interface {
|
||||
type DbAuth interface {
|
||||
GetUser(email string) (*User, error)
|
||||
}
|
||||
|
||||
type AuthSqlite struct {
|
||||
type DbAuthSqlite struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewAuthSqlite(db *sql.DB) *AuthSqlite {
|
||||
return &AuthSqlite{db: db}
|
||||
func NewDbAuthSqlite(db *sql.DB) *DbAuthSqlite {
|
||||
return &DbAuthSqlite{db: db}
|
||||
}
|
||||
|
||||
func (a AuthSqlite) GetUser(email string) (*User, error) {
|
||||
func (db DbAuthSqlite) GetUser(email string) (*User, error) {
|
||||
var (
|
||||
userId uuid.UUID
|
||||
emailVerified bool
|
||||
@@ -61,7 +61,7 @@ func (a AuthSqlite) GetUser(email string) (*User, error) {
|
||||
createdAt time.Time
|
||||
)
|
||||
|
||||
err := a.db.QueryRow(`
|
||||
err := db.db.QueryRow(`
|
||||
SELECT user_uuid, email_verified, email_verified_at, password, salt, created_at
|
||||
FROM user
|
||||
WHERE email = ?`, email).Scan(&userId, &emailVerified, &emailVerifiedAt, &password, &salt, &createdAt)
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestGetUser(t *testing.T) {
|
||||
db := setupDb(t)
|
||||
defer db.Close()
|
||||
|
||||
underTest := AuthSqlite{db: db}
|
||||
underTest := DbAuthSqlite{db: db}
|
||||
|
||||
_, err := underTest.GetUser("someNonExistentEmail")
|
||||
if err != UserNotFound {
|
||||
@@ -42,7 +42,7 @@ func TestGetUser(t *testing.T) {
|
||||
db := setupDb(t)
|
||||
defer db.Close()
|
||||
|
||||
underTest := AuthSqlite{db: db}
|
||||
underTest := DbAuthSqlite{db: db}
|
||||
|
||||
verifiedAt := time.Date(2020, 1, 5, 13, 0, 0, 0, time.UTC)
|
||||
createAt := time.Date(2020, 1, 5, 12, 0, 0, 0, time.UTC)
|
||||
|
||||
Reference in New Issue
Block a user