From 92b7f52a41a34c0908fb260e89c27415823e3c62 Mon Sep 17 00:00:00 2001 From: Nadia Mayor Date: Thu, 16 Nov 2023 12:31:32 -0300 Subject: [PATCH] [SDKS-7685] Add sets in SplitView --- splitio/client/manager.go | 6 ++++++ splitio/client/manager_test.go | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/splitio/client/manager.go b/splitio/client/manager.go index db35ab9..c9cb71c 100644 --- a/splitio/client/manager.go +++ b/splitio/client/manager.go @@ -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 { @@ -34,6 +35,10 @@ 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, @@ -41,6 +46,7 @@ func newSplitView(splitDto *dtos.SplitDTO) *SplitView { TrafficType: splitDto.TrafficTypeName, Treatments: treatments, Configs: splitDto.Configurations, + Sets: sets, } } diff --git a/splitio/client/manager_test.go b/splitio/client/manager_test.go index 12d03ac..9f7d85d 100644 --- a/splitio/client/manager_test.go +++ b/splitio/client/manager_test.go @@ -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{ @@ -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") @@ -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")