You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/__tests__/consumer/node_redis.spec.js
+14-3Lines changed: 14 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -157,18 +157,29 @@ tape('Node.js Redis', function (t) {
157
157
assert.equal(awaitclient.getTreatment('UT_Segment_member','hierarchical_splits_testing_on_negated'),'off','Evaluations using Redis storage should be correct.');
158
158
assert.equal(awaitclient.getTreatment('other_key','always-on-impressions-disabled-true'),'on','Evaluations using Redis storage should be correct.');
159
159
160
+
// Evaluations with rule-based segments
161
+
assert.equal(awaitclient.getTreatment('emi@split.io','rbs_test_flag'),'v2','key in excluded segment');
assert.equal(awaitclient.getTreatment('bilal@split.io','rbs_test_flag_negated'),'v2','key satisfies the rbs condition');
169
+
assert.equal(awaitclient.getTreatment('other_key','rbs_test_flag_negated'),'v1','key not in segment');
170
+
160
171
assert.equal(typeofclient.track().then,'function','Track calls should always return a promise on Redis mode, even when parameters are incorrect.');
161
172
162
173
assert.true(awaitclient.track('nicolas@split.io','user','test.redis.event',18),'If the event was successfully queued the promise will resolve to true');
163
174
assert.false(awaitclient.track(),'If the event was NOT successfully queued the promise will resolve to false');
164
175
165
176
// Manager methods
166
177
constsplitNames=awaitmanager.names();
167
-
assert.equal(splitNames.length,26,'manager `names` method returns the list of split names asynchronously');
178
+
assert.equal(splitNames.length,28,'manager `names` method returns the list of split names asynchronously');
168
179
assert.equal(splitNames.indexOf(expectedSplitName)>-1,true,'list of split names should contain expected splits');
169
180
assert.deepEqual(awaitmanager.split(expectedSplitName),expectedSplitView,'manager `split` method returns the split view of the given split name asynchronously');
170
181
constsplitViews=awaitmanager.splits();
171
-
assert.equal(splitViews.length,26,'manager `splits` method returns the list of split views asynchronously');
182
+
assert.equal(splitViews.length,28,'manager `splits` method returns the list of split views asynchronously');
172
183
assert.deepEqual(splitViews.find(splitView=>splitView.name===expectedSplitName),expectedSplitView,'manager `split` method returns the split view of the given split name asynchronously');
173
184
174
185
awaitclient.ready();// promise already resolved
@@ -188,7 +199,7 @@ tape('Node.js Redis', function (t) {
188
199
if(error)assert.fail('Redis server should be reachable');
assert.deepEqual(trackedImpressionsAndEvents,[TOTAL_RAW_IMPRESSIONS,TOTAL_EVENTS],'Tracked impressions and events should be stored in Redis');
202
+
assert.deepEqual(trackedImpressionsAndEvents,[TOTAL_RAW_IMPRESSIONS+8/* evaluations with rule-based segments */,TOTAL_EVENTS],'Tracked impressions and events should be stored in Redis');
Copy file name to clipboardExpand all lines: src/__tests__/mocks/redis-commands.txt
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -40,3 +40,8 @@ SET 'REDIS_NODE_UT.SPLITIO.split.testing_traffic_types' '{"changeNumber":149
40
40
SET 'REDIS_NODE_UT.SPLITIO.split.traffic_allocation_testing' '{"changeNumber":1490974123779,"trafficTypeName":"user","name":"traffic_allocation_testing","seed":1716284102,"status":"ACTIVE","killed":false,"defaultTreatment":"off","conditions":[{"matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"user","attribute":""},"matcherType":"ALL_KEYS","negate":false,"userDefinedSegmentMatcherData":{"segmentName":""},"unaryNumericMatcherData":{"dataType":"","value":0},"whitelistMatcherData":{"whitelist":null},"betweenMatcherData":{"dataType":"","start":0,"end":0}}]},"partitions":[{"treatment":"on","size":100},{"treatment":"off","size":0}],"label":"in segment all"}]}'
41
41
SET 'REDIS_NODE_UT.SPLITIO.splits.till' 1492723024413
42
42
SET 'REDIS_NODE_UT.SPLITIO.split.always-on-impressions-disabled-true' '{"changeNumber":1487277320548,"trafficTypeName":"user","name":"always-on-impressions-disabled-true","impressionsDisabled":true,"seed":1684183541,"status":"ACTIVE","killed":false,"defaultTreatment":"off","conditions":[{"matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"user","attribute":""},"matcherType":"ALL_KEYS","negate":false,"userDefinedSegmentMatcherData":{"segmentName":""},"unaryNumericMatcherData":{"dataType":"","value":0},"whitelistMatcherData":{"whitelist":null},"betweenMatcherData":{"dataType":"","start":0,"end":0}}]},"partitions":[{"treatment":"on","size":100},{"treatment":"off","size":0}],"label":"in segment all"}]}'
43
+
SET 'REDIS_NODE_UT.SPLITIO.split.rbs_test_flag' '{"changeNumber":10,"trafficTypeName":"user","name":"rbs_test_flag","trafficAllocation":100,"trafficAllocationSeed":1828377380,"seed":-286617921,"status":"ACTIVE","killed":false,"defaultTreatment":"off","algo":2,"conditions":[{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"user"},"matcherType":"IN_RULE_BASED_SEGMENT","negate":false,"userDefinedSegmentMatcherData":{"segmentName":"test_rule_based_segment"}}]},"partitions":[{"treatment":"v1","size":100},{"treatment":"v2","size":0}],"label":"in rule based segment test_rule_based_segment"},{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"user"},"matcherType":"ALL_KEYS","negate":false}]},"partitions":[{"treatment":"v1","size":0},{"treatment":"v2","size":100}],"label":"default rule"}],"configurations":{},"sets":[],"impressionsDisabled":false}'
44
+
SET 'REDIS_NODE_UT.SPLITIO.split.rbs_test_flag_negated' '{"changeNumber":10,"trafficTypeName":"user","name":"rbs_test_flag_negated","trafficAllocation":100,"trafficAllocationSeed":1828377380,"seed":-286617921,"status":"ACTIVE","killed":false,"defaultTreatment":"off","algo":2,"conditions":[{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"user"},"matcherType":"IN_RULE_BASED_SEGMENT","negate":true,"userDefinedSegmentMatcherData":{"segmentName":"test_rule_based_segment"}}]},"partitions":[{"treatment":"v1","size":100},{"treatment":"v2","size":0}],"label":"not in rule based segment test_rule_based_segment"},{"conditionType":"ROLLOUT","matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"user"},"matcherType":"ALL_KEYS","negate":false}]},"partitions":[{"treatment":"v1","size":0},{"treatment":"v2","size":100}],"label":"default rule"}],"configurations":{},"sets":[],"impressionsDisabled":false}'
45
+
SET 'REDIS_NODE_UT.SPLITIO.rbsegment.test_rule_based_segment' '{"changeNumber":5,"name":"test_rule_based_segment","status":"ACTIVE","trafficTypeName":"user","excluded":{"keys":["mauro@split.io","gaston@split.io"],"segments":["segment_excluded_by_rbs"]},"conditions":[{"matcherGroup":{"combiner":"AND","matchers":[{"keySelector":{"trafficType":"user"},"matcherType":"ENDS_WITH","negate":false,"whitelistMatcherData":{"whitelist":["@split.io"]}}]}}]}'
46
+
SET 'REDIS_NODE_UT.SPLITIO.rbsegments.till' 1492723024413
0 commit comments