(t *testing.T)
| 80 | } |
| 81 | |
| 82 | func TestGetUserByEmail(t *testing.T) { |
| 83 | t.Run("success", func(t *testing.T) { |
| 84 | db := testutils.InitMemoryDB(t) |
| 85 | |
| 86 | user := testutils.SetupUserData(db, "alice@example.com", "password123") |
| 87 | |
| 88 | a := NewTest() |
| 89 | a.DB = db |
| 90 | |
| 91 | foundUser, err := a.GetUserByEmail("alice@example.com") |
| 92 | |
| 93 | assert.Equal(t, err, nil, "should not error") |
| 94 | assert.Equal(t, foundUser.Email.String, "alice@example.com", "email mismatch") |
| 95 | assert.Equal(t, foundUser.ID, user.ID, "user ID mismatch") |
| 96 | }) |
| 97 | |
| 98 | t.Run("not found", func(t *testing.T) { |
| 99 | db := testutils.InitMemoryDB(t) |
| 100 | |
| 101 | a := NewTest() |
| 102 | a.DB = db |
| 103 | |
| 104 | user, err := a.GetUserByEmail("nonexistent@example.com") |
| 105 | |
| 106 | assert.Equal(t, err, ErrNotFound, "should return ErrNotFound") |
| 107 | assert.Equal(t, user, (*database.User)(nil), "user should be nil") |
| 108 | }) |
| 109 | } |
| 110 | |
| 111 | func TestGetAllUsers(t *testing.T) { |
| 112 | t.Run("success with multiple users", func(t *testing.T) { |
nothing calls this directly
no test coverage detected