Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDKS-7685] Add sets in SplitView #205

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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