| 357 | } |
| 358 | |
| 359 | func usersCount(t *testing.T, ctx context.Context, s *UsersStore) { |
| 360 | // Has no user initially |
| 361 | got := s.Count(ctx) |
| 362 | assert.Equal(t, int64(0), got) |
| 363 | |
| 364 | _, err := s.Create(ctx, "alice", "alice@example.com", CreateUserOptions{}) |
| 365 | require.NoError(t, err) |
| 366 | got = s.Count(ctx) |
| 367 | assert.Equal(t, int64(1), got) |
| 368 | |
| 369 | // Create an organization shouldn't count |
| 370 | // TODO: Use Orgs.Create to replace SQL hack when the method is available. |
| 371 | org1, err := s.Create(ctx, "org1", "org1@example.com", CreateUserOptions{}) |
| 372 | require.NoError(t, err) |
| 373 | err = s.db.Exec( |
| 374 | dbutil.Quote("UPDATE %s SET type = ? WHERE id = ?", "user"), |
| 375 | UserTypeOrganization, org1.ID, |
| 376 | ).Error |
| 377 | require.NoError(t, err) |
| 378 | got = s.Count(ctx) |
| 379 | assert.Equal(t, int64(1), got) |
| 380 | } |
| 381 | |
| 382 | func usersCreate(t *testing.T, ctx context.Context, s *UsersStore) { |
| 383 | alice, err := s.Create( |