Skip to content

Commit

Permalink
feat(api): save feature toggles config in redis
Browse files Browse the repository at this point in the history
  • Loading branch information
bpetetot committed Feb 5, 2025
1 parent 01fab18 commit d35a491
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class FeatureTogglesClient {
await this.storage.save({ key, value: featureToggle.defaultValue });
}
}

await this.storage.save({ key: '_config', value: this.config });
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ describe('Unit | Infrastructure | FeatureToggles | FeatureTogglesClient', functi
});

describe('init', function () {
it('initialize the storage with default values', async function () {
it('initialize the storage with config and default values', async function () {
// given
const featureToggles = new FeatureTogglesClient(storage);

// when
await featureToggles.init(config);

// then
const savedConfig = await storage.get('_config');
expect(savedConfig).to.deep.equal(config);

const all = await featureToggles.all();
expect(all).to.deep.equal({ myToggle1: false, myToggle2: true, myToggle3: 'foo' });
});
Expand All @@ -44,7 +47,7 @@ describe('Unit | Infrastructure | FeatureToggles | FeatureTogglesClient', functi

// then
const keys = await storage.keys('*');
expect(keys).to.deep.equal(['myToggle1', 'myToggle4']);
expect(keys).to.deep.equal(['myToggle1', 'myToggle4', '_config']);

const all = await featureToggles.all();
expect(all).to.deep.equal({ myToggle1: false, myToggle4: 1 });
Expand Down

0 comments on commit d35a491

Please sign in to comment.