File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,20 @@ type SplitDTO struct {
38
38
Configurations map [string ]string `json:"configurations"`
39
39
Sets []string `json:"sets"`
40
40
ImpressionsDisabled bool `json:"impressionsDisabled"`
41
+ Prerequisites []Prerequisite `json:"prerequisites"`
41
42
}
42
43
43
44
// MarshalBinary exports SplitDTO to JSON string
44
45
func (s SplitDTO ) MarshalBinary () (data []byte , err error ) {
45
46
return json .Marshal (s )
46
47
}
47
48
49
+ // Prerequisites structure to map a Prerequisite fetched from JSON message
50
+ type Prerequisite struct {
51
+ FeatureFlagName string `json:"n"`
52
+ Treatments []string `json:"ts"`
53
+ }
54
+
48
55
// ConditionDTO structure to map a Condition fetched from JSON message.
49
56
type ConditionDTO struct {
50
57
ConditionType string `json:"conditionType"`
Original file line number Diff line number Diff line change @@ -50,6 +50,18 @@ func TestSplitDTO(t *testing.T) {
50
50
t .Error ("Marshal struct mal formed [Configurations]" )
51
51
}
52
52
53
+ if splitChangesDtoFromMarshal .FeatureFlags .Splits [0 ].Prerequisites == nil {
54
+ t .Error ("Marshal struct mal formed [Prerequisites]" )
55
+ }
56
+
57
+ if splitChangesDtoFromMarshal .FeatureFlags .Splits [0 ].Prerequisites [0 ].FeatureFlagName != "rbs_test_flag" {
58
+ t .Error ("Marshal struct mal formed [Prerequisites]" )
59
+ }
60
+
61
+ if splitChangesDtoFromMarshal .FeatureFlags .Splits [0 ].Prerequisites [0 ].Treatments [0 ] != "v1" {
62
+ t .Error ("Marshal struct mal formed [Prerequisites]" )
63
+ }
64
+
53
65
if splitChangesDtoFromMarshal .FeatureFlags .Splits [0 ].Configurations ["of" ] !=
54
66
splitChangesDtoFromMock .FeatureFlags .Splits [0 ].Configurations ["of" ] {
55
67
t .Error ("Marshal struct mal formed [Configurations]" )
Original file line number Diff line number Diff line change 12
12
"configurations" : {
13
13
"on" : " {\" color\" : \" blue\" ,\" size\" : 13}"
14
14
},
15
+ "prerequisites" : [
16
+ {
17
+ "n" : " rbs_test_flag" ,
18
+ "ts" : [
19
+ " v1"
20
+ ]
21
+ }
22
+ ],
15
23
"conditions" : [
16
24
{
17
25
"conditionType" : " WHITELIST" ,
You can’t perform that action at this time.
0 commit comments