@@ -11,40 +11,16 @@ import {
11
11
validateTestAssignments ,
12
12
} from '../../test/testHelpers' ;
13
13
import { IAssignmentLogger } from '../assignment-logger' ;
14
- import { IConfigurationStore } from '../configuration-store' ;
14
+ import { IConfigurationStore } from '../configuration-store/configuration-store' ;
15
+ import { MemoryOnlyConfigurationStore } from '../configuration-store/memory.store' ;
15
16
import { MAX_EVENT_QUEUE_SIZE , POLL_INTERVAL_MS , POLL_JITTER_PCT } from '../constants' ;
16
17
import FlagConfigurationRequestor from '../flag-configuration-requestor' ;
17
18
import FetchHttpClient from '../http-client' ;
18
- import { Flag , VariationType } from '../interfaces' ;
19
+ import { Flag , ObfuscatedFlag , VariationType } from '../interfaces' ;
19
20
20
21
import EppoClient , { FlagConfigurationRequestParameters , checkTypeMatch } from './eppo-client' ;
21
22
22
- class TestConfigurationStore implements IConfigurationStore {
23
- private store : Record < string , string > = { } ;
24
- private _isInitialized = false ;
25
-
26
- public get < T > ( key : string ) : T {
27
- const rval = this . store [ key ] ;
28
- return rval ? JSON . parse ( rval ) : null ;
29
- }
30
-
31
- public setEntries < T > ( entries : Record < string , T > ) {
32
- Object . entries ( entries ) . forEach ( ( [ key , val ] ) => {
33
- this . store [ key ] = JSON . stringify ( val ) ;
34
- } ) ;
35
- this . _isInitialized = true ;
36
- }
37
-
38
- public getKeys ( ) : string [ ] {
39
- return Object . keys ( this . store ) ;
40
- }
41
-
42
- public isInitialized ( ) : boolean {
43
- return this . _isInitialized ;
44
- }
45
- }
46
-
47
- export async function init ( configurationStore : IConfigurationStore ) {
23
+ export async function init ( configurationStore : IConfigurationStore < Flag | ObfuscatedFlag > ) {
48
24
const httpClient = new FetchHttpClient (
49
25
'http://127.0.0.1:4000' ,
50
26
{
@@ -68,7 +44,7 @@ describe('EppoClient E2E test', () => {
68
44
json : ( ) => Promise . resolve ( ufc ) ,
69
45
} ) ;
70
46
} ) as jest . Mock ;
71
- const storage = new TestConfigurationStore ( ) ;
47
+ const storage = new MemoryOnlyConfigurationStore < Flag | ObfuscatedFlag > ( ) ;
72
48
73
49
beforeAll ( async ( ) => {
74
50
await init ( storage ) ;
@@ -312,7 +288,7 @@ describe('EppoClient E2E test', () => {
312
288
} ) ;
313
289
314
290
it ( 'returns null if getStringAssignment was called for the subject before any UFC was loaded' , ( ) => {
315
- const localClient = new EppoClient ( new TestConfigurationStore ( ) ) ;
291
+ const localClient = new EppoClient ( new MemoryOnlyConfigurationStore ( ) ) ;
316
292
expect ( localClient . getStringAssignment ( flagKey , 'subject-1' , { } , 'hello world' ) ) . toEqual (
317
293
'hello world' ,
318
294
) ;
@@ -580,7 +556,7 @@ describe('EppoClient E2E test', () => {
580
556
581
557
describe ( 'Eppo Client constructed with configuration request parameters' , ( ) => {
582
558
let client : EppoClient ;
583
- let thisStorage : IConfigurationStore ;
559
+ let thisStorage : IConfigurationStore < Flag | ObfuscatedFlag > ;
584
560
let requestConfiguration : FlagConfigurationRequestParameters ;
585
561
586
562
const flagKey = 'numeric_flag' ;
@@ -606,7 +582,7 @@ describe('EppoClient E2E test', () => {
606
582
sdkVersion : '1.0.0' ,
607
583
} ;
608
584
609
- thisStorage = new TestConfigurationStore ( ) ;
585
+ thisStorage = new MemoryOnlyConfigurationStore ( ) ;
610
586
611
587
// We only want to fake setTimeout() and clearTimeout()
612
588
jest . useFakeTimers ( {
0 commit comments