File tree Expand file tree Collapse file tree 2 files changed +31
-7
lines changed
src/sync/polling/updaters Expand file tree Collapse file tree 2 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { telemetryTrackerFactory } from '../../../../trackers/telemetryTracker';
14
14
import { splitNotifications } from '../../../streaming/__tests__/dataMocks' ;
15
15
import { RBSegmentsCacheInMemory } from '../../../../storages/inMemory/RBSegmentsCacheInMemory' ;
16
16
import { RB_SEGMENT_UPDATE , SPLIT_UPDATE } from '../../../streaming/constants' ;
17
+ import { IN_RULE_BASED_SEGMENT } from '../../../../utils/constants' ;
17
18
18
19
const ARCHIVED_FF = 'ARCHIVED' ;
19
20
@@ -84,13 +85,31 @@ const testFFEmptySet: ISplit =
84
85
conditions : [ ] ,
85
86
sets : [ ]
86
87
} ;
88
+ // @ts -ignore
89
+ const rbsWithExcludedSegment : IRBSegment = {
90
+ name : 'rbs' ,
91
+ status : 'ACTIVE' ,
92
+ conditions : [ ] ,
93
+ excluded : {
94
+ segments : [ {
95
+ type : 'standard' ,
96
+ name : 'C'
97
+ } , {
98
+ type : 'rule-based' ,
99
+ name : 'D'
100
+ } ]
101
+ }
102
+ } ;
87
103
88
104
test ( 'splitChangesUpdater / segments parser' , ( ) => {
105
+ let segments = parseSegments ( activeSplitWithSegments as ISplit ) ;
106
+ expect ( segments ) . toEqual ( new Set ( [ 'A' , 'B' ] ) ) ;
89
107
90
- const segments = parseSegments ( activeSplitWithSegments as ISplit ) ;
108
+ segments = parseSegments ( rbsWithExcludedSegment ) ;
109
+ expect ( segments ) . toEqual ( new Set ( [ 'C' ] ) ) ;
91
110
92
- expect ( segments . has ( 'A' ) ) . toBe ( true ) ;
93
- expect ( segments . has ( 'B' ) ) . toBe ( true ) ;
111
+ segments = parseSegments ( rbsWithExcludedSegment , IN_RULE_BASED_SEGMENT ) ;
112
+ expect ( segments ) . toEqual ( new Set ( [ 'D' ] ) ) ;
94
113
} ) ;
95
114
96
115
test ( 'splitChangesUpdater / compute splits mutation' , ( ) => {
Original file line number Diff line number Diff line change @@ -26,15 +26,20 @@ function checkAllSegmentsExist(segments: ISegmentsCacheBase): Promise<boolean> {
26
26
}
27
27
28
28
/**
29
- * Collect segments from a raw split definition.
29
+ * Collect segments from a raw FF or RBS definition.
30
30
* Exported for testing purposes.
31
31
*/
32
32
export function parseSegments ( ruleEntity : ISplit | IRBSegment , matcherType : typeof IN_SEGMENT | typeof IN_RULE_BASED_SEGMENT = IN_SEGMENT ) : Set < string > {
33
33
const { conditions = [ ] , excluded } = ruleEntity as IRBSegment ;
34
34
35
- const segments = new Set < string > (
36
- excluded && excluded . segments ? excluded . segments . map ( segment => segment . name ) : [ ]
37
- ) ;
35
+ const segments = new Set < string > ( ) ;
36
+ if ( excluded && excluded . segments ) {
37
+ excluded . segments . forEach ( ( { type, name } ) => {
38
+ if ( ( type === 'standard' && matcherType === IN_SEGMENT ) || ( type === 'rule-based' && matcherType === IN_RULE_BASED_SEGMENT ) ) {
39
+ segments . add ( name ) ;
40
+ }
41
+ } ) ;
42
+ }
38
43
39
44
for ( let i = 0 ; i < conditions . length ; i ++ ) {
40
45
const matchers = conditions [ i ] . matcherGroup . matchers ;
You can’t perform that action at this time.
0 commit comments