(t *testing.T, ctx context.Context, s *UsersStore)
| 1195 | } |
| 1196 | |
| 1197 | func usersGetEmail(t *testing.T, ctx context.Context, s *UsersStore) { |
| 1198 | const testUserID = 1 |
| 1199 | const testEmail = "alice@example.com" |
| 1200 | _, err := s.GetEmail(ctx, testUserID, testEmail, false) |
| 1201 | wantErr := ErrEmailNotExist{ |
| 1202 | args: errutil.Args{ |
| 1203 | "email": testEmail, |
| 1204 | }, |
| 1205 | } |
| 1206 | assert.Equal(t, wantErr, err) |
| 1207 | |
| 1208 | err = s.AddEmail(ctx, testUserID, testEmail, false) |
| 1209 | require.NoError(t, err) |
| 1210 | got, err := s.GetEmail(ctx, testUserID, testEmail, false) |
| 1211 | require.NoError(t, err) |
| 1212 | assert.Equal(t, testEmail, got.Email) |
| 1213 | |
| 1214 | // Should not return if we ask for a different user |
| 1215 | _, err = s.GetEmail(ctx, testUserID+1, testEmail, false) |
| 1216 | assert.Equal(t, wantErr, err) |
| 1217 | |
| 1218 | // Should not return if we only want activated emails |
| 1219 | _, err = s.GetEmail(ctx, testUserID, testEmail, true) |
| 1220 | assert.Equal(t, wantErr, err) |
| 1221 | |
| 1222 | err = s.MarkEmailActivated(ctx, testUserID, testEmail) |
| 1223 | require.NoError(t, err) |
| 1224 | got, err = s.GetEmail(ctx, testUserID, testEmail, true) |
| 1225 | require.NoError(t, err) |
| 1226 | assert.Equal(t, testEmail, got.Email) |
| 1227 | } |
| 1228 | |
| 1229 | func usersListEmails(t *testing.T, ctx context.Context, s *UsersStore) { |
| 1230 | t.Run("list emails with primary email", func(t *testing.T) { |
nothing calls this directly
no test coverage detected