(t *testing.T, ctx context.Context, s *UsersStore)
| 1281 | } |
| 1282 | |
| 1283 | func usersMarkEmailPrimary(t *testing.T, ctx context.Context, s *UsersStore) { |
| 1284 | alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) |
| 1285 | require.NoError(t, err) |
| 1286 | err = s.AddEmail(ctx, alice.ID, "alice2@example.com", false) |
| 1287 | require.NoError(t, err) |
| 1288 | |
| 1289 | // Should fail because email not verified |
| 1290 | gotError := s.MarkEmailPrimary(ctx, alice.ID, "alice2@example.com") |
| 1291 | wantError := ErrEmailNotVerified{args: errutil.Args{"email": "alice2@example.com"}} |
| 1292 | assert.Equal(t, wantError, gotError) |
| 1293 | |
| 1294 | // Mark email as verified and should succeed |
| 1295 | err = s.MarkEmailActivated(ctx, alice.ID, "alice2@example.com") |
| 1296 | require.NoError(t, err) |
| 1297 | err = s.MarkEmailPrimary(ctx, alice.ID, "alice2@example.com") |
| 1298 | require.NoError(t, err) |
| 1299 | gotAlice, err := s.GetByID(ctx, alice.ID) |
| 1300 | require.NoError(t, err) |
| 1301 | assert.Equal(t, "alice2@example.com", gotAlice.Email) |
| 1302 | |
| 1303 | // Former primary email should be preserved |
| 1304 | gotEmail, err := s.GetEmail(ctx, alice.ID, "alice@example.com", false) |
| 1305 | require.NoError(t, err) |
| 1306 | assert.False(t, gotEmail.IsActivated) |
| 1307 | } |
| 1308 | |
| 1309 | func usersDeleteEmail(t *testing.T, ctx context.Context, s *UsersStore) { |
| 1310 | alice, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) |
nothing calls this directly
no test coverage detected