Skip to content

Commit

Permalink
[SDKS-7685] Add sets in SplitView
Browse files Browse the repository at this point in the history
  • Loading branch information
nmayorsplit committed Nov 16, 2023
1 parent bee091f commit 92b7f52
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions splitio/client/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type SplitView struct {
Treatments []string `json:"treatments"`
ChangeNumber int64 `json:"changeNumber"`
Configs map[string]string `json:"configs"`
Sets []string `json:"sets"`
}

func newSplitView(splitDto *dtos.SplitDTO) *SplitView {
Expand All @@ -34,13 +35,18 @@ func newSplitView(splitDto *dtos.SplitDTO) *SplitView {
treatments = append(treatments, partition.Treatment)
}
}
sets := []string{}
if splitDto.Sets != nil {
sets = splitDto.Sets
}
return &SplitView{
ChangeNumber: splitDto.ChangeNumber,
Killed: splitDto.Killed,
Name: splitDto.Name,
TrafficType: splitDto.TrafficTypeName,
Treatments: treatments,
Configs: splitDto.Configurations,
Sets: sets,
}
}

Expand Down
9 changes: 9 additions & 0 deletions splitio/client/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func TestSplitManager(t *testing.T) {
Name: "split1",
Killed: false,
TrafficTypeName: "tt1",
Sets: []string{"set1", "set2"},
Conditions: []dtos.ConditionDTO{
{
Partitions: []dtos.PartitionDTO{
Expand Down Expand Up @@ -71,6 +72,10 @@ func TestSplitManager(t *testing.T) {
t.Error("Incorrect treatments for split 1")
}

if len(s1.Sets) != 2 {
t.Error("split1 should have 2 sets")
}

s2 := manager.Split("split2")
if s2.Name != "split2" || !s2.Killed || s2.TrafficType != "tt2" || s2.ChangeNumber != 123 {
t.Error("Split 2 stored incorrectly")
Expand All @@ -79,6 +84,10 @@ func TestSplitManager(t *testing.T) {
t.Error("Incorrect treatments for split 2")
}

if s2.Sets == nil && len(s2.Sets) != 0 {
t.Error("split2 sets should be empty array")
}

all := manager.Splits()
if len(all) != 2 {
t.Error("Incorrect number of splits returned")
Expand Down

0 comments on commit 92b7f52

Please sign in to comment.