mirror of
https://github.com/bitwarden/server
synced 2026-01-27 06:43:19 +00:00
* Add sproc to create multiple default collections. SqlBulkCopy implementation is overkill for most cases. This provides a lighter weight sproc implementation for smaller data sets. * DRY up collection arrangement * DRY up tests because bulk and non-bulk share same behavior * use EF native AddRange instead of bulk insert, because we expect smaller data sizes on self-host
54 lines
2.1 KiB
C#
54 lines
2.1 KiB
C#
using Bit.Core.Repositories;
|
|
using Xunit;
|
|
|
|
namespace Bit.Infrastructure.IntegrationTest.AdminConsole.Repositories.CollectionRepository;
|
|
|
|
|
|
public class CreateDefaultCollectionsBulkAsyncTests
|
|
{
|
|
[Theory, DatabaseData]
|
|
public async Task CreateDefaultCollectionsBulkAsync_CreatesDefaultCollections_Success(
|
|
IOrganizationRepository organizationRepository,
|
|
IUserRepository userRepository,
|
|
IOrganizationUserRepository organizationUserRepository,
|
|
ICollectionRepository collectionRepository)
|
|
{
|
|
await CreateDefaultCollectionsSharedTests.CreatesDefaultCollections_Success(
|
|
collectionRepository.CreateDefaultCollectionsBulkAsync,
|
|
organizationRepository,
|
|
userRepository,
|
|
organizationUserRepository,
|
|
collectionRepository);
|
|
}
|
|
|
|
[Theory, DatabaseData]
|
|
public async Task CreateDefaultCollectionsBulkAsync_CreatesForNewUsersOnly_AndIgnoresExistingUsers(
|
|
IOrganizationRepository organizationRepository,
|
|
IUserRepository userRepository,
|
|
IOrganizationUserRepository organizationUserRepository,
|
|
ICollectionRepository collectionRepository)
|
|
{
|
|
await CreateDefaultCollectionsSharedTests.CreatesForNewUsersOnly_AndIgnoresExistingUsers(
|
|
collectionRepository.CreateDefaultCollectionsBulkAsync,
|
|
organizationRepository,
|
|
userRepository,
|
|
organizationUserRepository,
|
|
collectionRepository);
|
|
}
|
|
|
|
[Theory, DatabaseData]
|
|
public async Task CreateDefaultCollectionsBulkAsync_IgnoresAllExistingUsers(
|
|
IOrganizationRepository organizationRepository,
|
|
IUserRepository userRepository,
|
|
IOrganizationUserRepository organizationUserRepository,
|
|
ICollectionRepository collectionRepository)
|
|
{
|
|
await CreateDefaultCollectionsSharedTests.IgnoresAllExistingUsers(
|
|
collectionRepository.CreateDefaultCollectionsBulkAsync,
|
|
organizationRepository,
|
|
userRepository,
|
|
organizationUserRepository,
|
|
collectionRepository);
|
|
}
|
|
}
|