Skip to content

Commit 9b990d9

Browse files
Fix date
Signed-off-by: Thomas Poignant <[email protected]>
1 parent 291bd84 commit 9b990d9

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

libs/providers/go-feature-flag/src/lib/evaluator/inprocess-evaluator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export class InProcessEvaluator implements IEvaluator {
6565
*/
6666
async initialize(): Promise<void> {
6767
await this.evaluationEngine.initialize();
68-
6968
await this.loadConfiguration(true);
7069
// Start periodic configuration polling
7170
if (this.options.flagChangePollingIntervalMs && this.options.flagChangePollingIntervalMs > 0) {

libs/providers/go-feature-flag/src/lib/go-feature-flag-provider.test.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,11 @@ describe('GoFeatureFlagProvider', () => {
967967
it('Should change evaluation details if config has changed', async () => {
968968
jest.useRealTimers();
969969
let callCount = 0;
970-
fetchMock.mockIf(/^http:\/\/localhost:1031\/v1\/flag\/configuration/, async () => {
970+
fetchMock.mockIf(/^http:\/\/localhost:1031\/v1\/flag\/configuration/, async (request) => {
971+
// read headers in the request
972+
const headers = request.headers;
973+
console.log('headers', headers.get('If-None-Match'));
974+
971975
callCount++;
972976
if (callCount <= 1) {
973977
return {
@@ -1077,14 +1081,21 @@ describe('GoFeatureFlagProvider', () => {
10771081
});
10781082

10791083
it('Should apply a scheduled rollout step', async () => {
1080-
fetchMock.mockResponseOnce(getConfigurationEndpointResult('scheduled-rollout'), {
1081-
status: 200,
1082-
headers: { 'Content-Type': 'application/json' },
1084+
jest.useRealTimers();
1085+
fetchMock.mockIf(/^http:\/\/localhost:1031\/v1\/flag\/configuration/, async () => {
1086+
const res = getConfigurationEndpointResult('scheduled-rollout');
1087+
return {
1088+
body: res,
1089+
status: 200,
1090+
headers: {
1091+
'Content-Type': 'application/json',
1092+
},
1093+
};
10831094
});
10841095

10851096
const provider = new GoFeatureFlagProvider({
10861097
endpoint: 'http://localhost:1031',
1087-
flagChangePollingIntervalMs: 100,
1098+
flagChangePollingIntervalMs: 150,
10881099
});
10891100

10901101
await OpenFeature.setProviderAndWait(testClientName, provider);
@@ -1105,7 +1116,7 @@ describe('GoFeatureFlagProvider', () => {
11051116
});
11061117

11071118
it('Should not apply a scheduled rollout in the future', async () => {
1108-
jest.setSystemTime(new Date('2021-01-01T00:00:00Z'));
1119+
jest.setSystemTime(new Date('2021-01-01T01:00:00Z'));
11091120
fetchMock.mockIf(/^http:\/\/localhost:1031\/v1\/flag\/configuration/, async () => {
11101121
return {
11111122
body: getConfigurationEndpointResult('scheduled-rollout'),
@@ -1452,7 +1463,7 @@ describe('GoFeatureFlagProvider', () => {
14521463
});
14531464
});
14541465

1455-
function getConfigurationEndpointResult(mode = 'default') {
1466+
function getConfigurationEndpointResult(mode = 'default'): string {
14561467
const filePath = path.resolve(__dirname, 'testdata', 'flag-configuration', mode + '.json');
14571468
const fileContent = fs.readFileSync(filePath, 'utf-8');
14581469
return JSON.stringify(JSON.parse(fileContent));

0 commit comments

Comments
 (0)