From d734a7cd736d9616bdcb14650d4b963c1ece4c18 Mon Sep 17 00:00:00 2001 From: Jouko Virtanen Date: Fri, 15 Nov 2024 14:22:12 -0800 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Giles Hutton --- integration-tests/pkg/mock_sensor/expect_conn.go | 3 +-- integration-tests/pkg/mock_sensor/server.go | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/integration-tests/pkg/mock_sensor/expect_conn.go b/integration-tests/pkg/mock_sensor/expect_conn.go index dd2be10ae9..849a05e4a7 100644 --- a/integration-tests/pkg/mock_sensor/expect_conn.go +++ b/integration-tests/pkg/mock_sensor/expect_conn.go @@ -103,8 +103,7 @@ func (s *MockSensor) ExpectSameElementsConnections(t *testing.T, containerID str types.SortConnections(expected) connections := s.SortedConnections(containerID) - success := s.checkIfConnectionsMatchExpected(t, connections, expected) - if success { + if s.checkIfConnectionsMatchExpected(t, connections, expected) { return true } diff --git a/integration-tests/pkg/mock_sensor/server.go b/integration-tests/pkg/mock_sensor/server.go index fc7febafc7..9a5f072f68 100644 --- a/integration-tests/pkg/mock_sensor/server.go +++ b/integration-tests/pkg/mock_sensor/server.go @@ -155,7 +155,9 @@ func (m *MockSensor) Connections(containerID string) []types.NetworkInfo { defer m.networkMutex.Unlock() if connections, ok := m.connections[containerID]; ok { - return connections + conns := make([]types.NetworkInfo, len(connections)) + copy(conns, connections) + return conns } return make([]types.NetworkInfo, 0) }