-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsegment-recursion.yml
More file actions
121 lines (104 loc) · 3.9 KB
/
Copy pathsegment-recursion.yml
File metadata and controls
121 lines (104 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
# FLGEA 1.6.2.5: segment matching with circular reference detection
name: segment recursion
constants:
IS_MATCH:
value: true
variationIndex: 0
reason: { kind: "RULE_MATCH", ruleIndex: 0, ruleId: "ruleid" }
IS_NOT_MATCH:
value: false
variationIndex: 1
reason: { kind: "FALLTHROUGH" }
boolean_flag_base: &boolean_flag_base
on: true
variations: [ true, false ]
offVariation: 1
fallthrough: { variation: 1 }
parameters:
- NAME: simple single-level recursion
FLAG_USES_SEGMENT: recursive-segment-1
RECURSIVE_SEGMENT_1_USES: segment-that-always-matches
CONTEXT: { kind: "user", key: "user-key" }
EXPECT: <IS_MATCH>
- NAME: single level, two clauses in one rule, both match
FLAG_USES_SEGMENT: segment-requiring-both-of-two-segments
CONTEXT: { kind: "user", key: "user-key", "segment-with-rule-a-should-match": true, "segment-with-rule-b-should-match": true }
EXPECT: <IS_MATCH>
- NAME: single level, two clauses in one rule, one does not match
FLAG_USES_SEGMENT: segment-requiring-both-of-two-segments
CONTEXT: { kind: "user", key: "user-key", "segment-with-rule-a-should-match": false, "segment-with-rule-b-should-match": true }
EXPECT: <IS_NOT_MATCH>
- NAME: single level, two rules, one does not match
FLAG_USES_SEGMENT: segment-requiring-either-of-two-segments
CONTEXT: { kind: "user", key: "user-key", "segment-with-rule-a-should-match": false, "segment-with-rule-b-should-match": true }
EXPECT: <IS_MATCH>
- NAME: cycle is detected at top level, recursion stops
FLAG_USES_SEGMENT: recursive-segment-1
RECURSIVE_SEGMENT_1_USES: recursive-segment-2
RECURSIVE_SEGMENT_2_USES: recursive-segment-3
RECURSIVE_SEGMENT_3_USES: recursive-segment-1
CONTEXT: { kind: "user", key: "user-key" }
EXPECT:
value: false
reason: { kind: "ERROR", errorKind: "MALFORMED_FLAG" }
- NAME: cycle is detected below top level, recursion stops
FLAG_USES_SEGMENT: recursive-segment-1
RECURSIVE_SEGMENT_1_USES: recursive-segment-2
RECURSIVE_SEGMENT_2_USES: recursive-segment-3
RECURSIVE_SEGMENT_3_USES: recursive-segment-2
CONTEXT: { kind: "user", key: "user-key" }
EXPECT:
value: false
reason: { kind: "ERROR", errorKind: "MALFORMED_FLAG" }
sdkData:
flags:
flag-using-segment:
<<: *boolean_flag_base
rules:
- id: ruleid
variation: 0
clauses:
- { attribute: "", op: "segmentMatch", values: [ "<FLAG_USES_SEGMENT>" ]}
segments:
recursive-segment-1:
rules:
- clauses:
- { op: "segmentMatch", values: [ "<RECURSIVE_SEGMENT_1_USES>" ] }
recursive-segment-2:
rules:
- clauses:
- { op: "segmentMatch", values: [ "<RECURSIVE_SEGMENT_2_USES>" ] }
recursive-segment-3:
rules:
- clauses:
- { op: "segmentMatch", values: [ "<RECURSIVE_SEGMENT_3_USES>" ] }
segment-that-always-matches:
rules:
- clauses:
- { attribute: "key", op: "in", values: [ "" ], negate: true }
segment-with-rule-a:
rules:
- clauses:
- { attribute: "segment-with-rule-a-should-match", op: "in", values: [ true ] }
segment-with-rule-b:
rules:
- clauses:
- { attribute: "segment-with-rule-b-should-match", op: "in", values: [ true ] }
segment-requiring-both-of-two-segments:
rules:
- clauses:
- { op: "segmentMatch", values: [ "segment-with-rule-a" ] }
- { op: "segmentMatch", values: [ "segment-with-rule-b" ] }
segment-requiring-either-of-two-segments:
rules:
- clauses:
- { op: "segmentMatch", values: [ "segment-with-rule-a" ] }
- clauss:
- { op: "segmentMatch", values: [ "segment-with-rule-b" ] }
evaluations:
- name: <NAME>
flagKey: flag-using-segment
context: <CONTEXT>
default: false
expect: <EXPECT>