1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

fix duplicate test key for dbInit

This commit is contained in:
Christopher Kolstad 2021-09-16 11:09:49 +02:00
parent 1ae90f6942
commit e257be361b
No known key found for this signature in database
GPG Key ID: 559ACB0E3DB5538A
5 changed files with 27 additions and 7 deletions

View File

@ -174,6 +174,7 @@ class FeatureController extends Controller {
s, s,
createdFeature.project, createdFeature.project,
createdFeature.name, createdFeature.name,
userName,
), ),
), ),
); );
@ -219,6 +220,7 @@ class FeatureController extends Controller {
s, s,
projectId, projectId,
featureName, featureName,
userName,
), ),
), ),
); );

View File

@ -32,6 +32,7 @@ beforeAll(async () => {
strategy, strategy,
projectId, projectId,
toggle.name, toggle.name,
username,
); );
}; };
@ -273,6 +274,7 @@ test('can not toggle of feature that does not exist', async () => {
test('can toggle a feature that does exist', async () => { test('can toggle a feature that does exist', async () => {
expect.assertions(0); expect.assertions(0);
const featureName = 'existing.feature'; const featureName = 'existing.feature';
const username = 'toggle-feature';
const feature = const feature =
await app.services.featureToggleServiceV2.createFeatureToggle( await app.services.featureToggleServiceV2.createFeatureToggle(
'default', 'default',
@ -285,6 +287,7 @@ test('can toggle a feature that does exist', async () => {
defaultStrategy, defaultStrategy,
'default', 'default',
featureName, featureName,
username,
); );
return app.request return app.request
.post(`/api/admin/features/${feature.name}/toggle`) .post(`/api/admin/features/${feature.name}/toggle`)

View File

@ -57,6 +57,7 @@ beforeAll(async () => {
}, },
project, project,
feature1, feature1,
username,
); );
await featureToggleServiceV2.createStrategy( await featureToggleServiceV2.createStrategy(
{ {

View File

@ -27,6 +27,8 @@ afterAll(async () => {
}); });
test('Should create feature toggle strategy configuration', async () => { test('Should create feature toggle strategy configuration', async () => {
const projectId = 'default';
const username = 'feature-toggle';
const config: Omit<IStrategyConfig, 'id'> = { const config: Omit<IStrategyConfig, 'id'> = {
name: 'default', name: 'default',
constraints: [], constraints: [],
@ -43,8 +45,9 @@ test('Should create feature toggle strategy configuration', async () => {
const createdConfig = await service.createStrategy( const createdConfig = await service.createStrategy(
config, config,
'default', projectId,
'Demo', 'Demo',
username,
); );
expect(createdConfig.name).toEqual('default'); expect(createdConfig.name).toEqual('default');
@ -52,6 +55,8 @@ test('Should create feature toggle strategy configuration', async () => {
}); });
test('Should be able to update existing strategy configuration', async () => { test('Should be able to update existing strategy configuration', async () => {
const projectId = 'default';
const username = 'existing-strategy';
const config: Omit<IStrategyConfig, 'id'> = { const config: Omit<IStrategyConfig, 'id'> = {
name: 'default', name: 'default',
constraints: [], constraints: [],
@ -59,7 +64,7 @@ test('Should be able to update existing strategy configuration', async () => {
}; };
await service.createFeatureToggle( await service.createFeatureToggle(
'default', projectId,
{ {
name: 'update-existing-strategy', name: 'update-existing-strategy',
}, },
@ -70,11 +75,18 @@ test('Should be able to update existing strategy configuration', async () => {
config, config,
'default', 'default',
'update-existing-strategy', 'update-existing-strategy',
username,
); );
expect(createdConfig.name).toEqual('default'); expect(createdConfig.name).toEqual('default');
const updatedConfig = await service.updateStrategy(createdConfig.id, { const updatedConfig = await service.updateStrategy(
parameters: { b2b: true }, createdConfig.id,
}); GLOBAL_ENV,
projectId,
username,
{
parameters: { b2b: true },
},
);
expect(createdConfig.id).toEqual(updatedConfig.id); expect(createdConfig.id).toEqual(updatedConfig.id);
expect(updatedConfig.parameters).toEqual({ b2b: true }); expect(updatedConfig.parameters).toEqual({ b2b: true });
}); });
@ -96,7 +108,7 @@ test('Should include legacy props in event log when updating strategy configurat
userName, userName,
); );
await service.createStrategy(config, 'default', featureName); await service.createStrategy(config, 'default', featureName, userName);
await service.updateEnabled( await service.updateEnabled(
'default', 'default',
featureName, featureName,
@ -112,6 +124,7 @@ test('Should include legacy props in event log when updating strategy configurat
}); });
test('Should be able to get strategy by id', async () => { test('Should be able to get strategy by id', async () => {
const userName = 'strategy';
const config: Omit<IStrategyConfig, 'id'> = { const config: Omit<IStrategyConfig, 'id'> = {
name: 'default', name: 'default',
constraints: [], constraints: [],
@ -130,6 +143,7 @@ test('Should be able to get strategy by id', async () => {
config, config,
'default', 'default',
'Demo', 'Demo',
userName,
); );
const fetchedConfig = await service.getStrategy(createdConfig.id); const fetchedConfig = await service.getStrategy(createdConfig.id);
expect(fetchedConfig).toEqual(createdConfig); expect(fetchedConfig).toEqual(createdConfig);

View File

@ -10,7 +10,7 @@ let userStore: IUserStore;
let currentUser; let currentUser;
beforeAll(async () => { beforeAll(async () => {
db = await dbInit('project_store_serial', getLogger); db = await dbInit('user_feedback_store', getLogger);
stores = db.stores; stores = db.stores;
userFeedbackStore = stores.userFeedbackStore; userFeedbackStore = stores.userFeedbackStore;
userStore = stores.userStore; userStore = stores.userStore;