From 2b211461853f948368b7d848747bfc258155b06b Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 7 Jun 2022 04:59:21 +0300 Subject: [PATCH] [#227] netmap/test: Assert source placement builder is pure for nodes `GetContainerNodes` / `GetPlacementVectors` must not mutate source slice of nodes. Signed-off-by: Leonard Lyubich --- netmap/json_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/netmap/json_test.go b/netmap/json_test.go index e0fd0e57..19c1608b 100644 --- a/netmap/json_test.go +++ b/netmap/json_test.go @@ -52,6 +52,9 @@ func TestPlacementPolicy_Interopability(t *testing.T) { var tc TestCase require.NoError(t, json.Unmarshal(bs, &tc), "cannot unmarshal %s", ds[i].Name()) + srcNodes := make([]NodeInfo, len(tc.Nodes)) + copy(srcNodes, tc.Nodes) + t.Run(tc.Name, func(t *testing.T) { nodes := NodesFromInfo(tc.Nodes) nm, err := NewNetmap(nodes) @@ -65,6 +68,7 @@ func TestPlacementPolicy_Interopability(t *testing.T) { require.Contains(t, err.Error(), tt.Error) } else { require.NoError(t, err) + require.Equal(t, srcNodes, tc.Nodes) res := v.Replicas() compareNodes(t, tt.Result, nodes, res) @@ -73,6 +77,7 @@ func TestPlacementPolicy_Interopability(t *testing.T) { res, err := nm.GetPlacementVectors(v, tt.Placement.Pivot) require.NoError(t, err) compareNodes(t, tt.Placement.Result, nodes, res) + require.Equal(t, srcNodes, tc.Nodes) } } })