Skip to content

Commit

Permalink
Using slices.ContainsFunc in HasConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
JoukoVirtanen committed Nov 14, 2024
1 parent 4583ed4 commit 9b4f72e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions integration-tests/pkg/mock_sensor/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log"
"net"
"os"
"slices"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -166,11 +167,9 @@ func (m *MockSensor) HasConnection(containerID string, conn types.NetworkInfo) b
defer m.networkMutex.Unlock()

if conns, ok := m.connections[containerID]; ok {
for _, connection := range conns {
if connection.Equal(conn) {
return true
}
}
return slices.ContainsFunc(conns, func(c types.NetworkInfo) bool {
return c.Equal(conn)
})
}

return false
Expand Down

0 comments on commit 9b4f72e

Please sign in to comment.