feat: sqlite: implement GetUserByEmail
This commit is contained in:
parent
9918c9918f
commit
7c9b7aa154
3 changed files with 61 additions and 4 deletions
|
|
@ -28,6 +28,7 @@ import (
|
|||
type SuiteStore interface {
|
||||
CreateUser(ctx context.Context, u *store.User) error
|
||||
GetUserByID(ctx context.Context, id string) (*store.User, error)
|
||||
GetUserByEmail(ctx context.Context, email string) (*store.User, error)
|
||||
}
|
||||
|
||||
// Factory returns a fresh, isolated Store. Each call to the factory must
|
||||
|
|
@ -53,6 +54,7 @@ func RunSuite(t *testing.T, newStore Factory) {
|
|||
{"GetUserByID_notFound", testGetUserByIDNotFound},
|
||||
{"CreateUser_duplicateEmail", testCreateUserDuplicateEmail},
|
||||
{"CreateUser_duplicateUsernameNormalized", testCreateUserDuplicateUsernameNormalized},
|
||||
{"CreateUser_GetUserByEmail_roundTrip", testCreateUserGetUserByEmailRoundTrip},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
|
@ -138,6 +140,22 @@ func testCreateUserDuplicateUsernameNormalized(t *testing.T, s SuiteStore) {
|
|||
}
|
||||
}
|
||||
|
||||
func testCreateUserGetUserByEmailRoundTrip(t *testing.T, s SuiteStore) {
|
||||
ctx := context.Background()
|
||||
|
||||
want := FixedUser()
|
||||
if err := s.CreateUser(ctx, want); err != nil {
|
||||
t.Fatalf("CreateUser: %v", err)
|
||||
}
|
||||
|
||||
got, err := s.GetUserByEmail(ctx, want.Email)
|
||||
if err != nil {
|
||||
t.Fatalf("GetUserByEmail: %v", err)
|
||||
}
|
||||
|
||||
AssertUserEqual(t, got, want)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Fixtures and helpers. Exported so dialect-specific tests can reuse them
|
||||
// for one-off cases that don't fit into the shared suite.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue