conntrackfixer: fix tests for deprecation of NetworkSettingsBase

This commit is contained in:
Vincent Bernat
2025-09-14 12:21:45 +02:00
parent a3714a749b
commit 2aaf984552
3 changed files with 23 additions and 25 deletions

View File

@@ -58,24 +58,22 @@ func TestRoot(t *testing.T) {
Return(dockerEvents, dockerErrors)
// Initial trigger
networkSettings := &container.NetworkSettings{}
networkSettings.Ports = map[nat.Port][]nat.PortBinding{
"2055/udp": {
nat.PortBinding{
HostIP: "127.0.0.1",
HostPort: "6776",
},
},
}
dockerClientMock.EXPECT().
ContainerList(gomock.Any(), gomock.Any()).
Return([]container.Summary{{ID: "initial"}}, nil)
dockerClientMock.EXPECT().
ContainerInspect(gomock.Any(), "initial").
Return(container.InspectResponse{
NetworkSettings: &container.NetworkSettings{
NetworkSettingsBase: container.NetworkSettingsBase{
Ports: map[nat.Port][]nat.PortBinding{
"2055/udp": {
nat.PortBinding{
HostIP: "127.0.0.1",
HostPort: "6776",
},
},
},
},
},
NetworkSettings: networkSettings,
}, nil)
conntrackConnMock.EXPECT().
Dump(nil).
@@ -133,24 +131,22 @@ func TestRoot(t *testing.T) {
// New container
t.Run("new container", func(_ *testing.T) {
networkSettings := &container.NetworkSettings{}
networkSettings.Ports = map[nat.Port][]nat.PortBinding{
"2055/udp": {
nat.PortBinding{
HostIP: "127.0.0.1",
HostPort: "6777",
},
},
}
dockerClientMock.EXPECT().
ContainerList(gomock.Any(), gomock.Any()).
Return([]container.Summary{{ID: "new one"}}, nil)
dockerClientMock.EXPECT().
ContainerInspect(gomock.Any(), "new one").
Return(container.InspectResponse{
NetworkSettings: &container.NetworkSettings{
NetworkSettingsBase: container.NetworkSettingsBase{
Ports: map[nat.Port][]nat.PortBinding{
"2055/udp": {
nat.PortBinding{
HostIP: "127.0.0.1",
HostPort: "6777",
},
},
},
},
},
NetworkSettings: networkSettings,
}, nil)
conntrackConnMock.EXPECT().
Dump(nil).

2
go.mod
View File

@@ -13,7 +13,7 @@ require (
github.com/bits-and-blooms/bitset v1.24.0
github.com/cenkalti/backoff/v4 v4.3.0
github.com/chenyahui/gin-cache v1.10.0
github.com/docker/docker v28.3.3+incompatible
github.com/docker/docker v28.4.0+incompatible
github.com/docker/go-connections v0.6.0
github.com/eapache/go-resiliency v1.7.0
github.com/expr-lang/expr v1.17.6

2
go.sum
View File

@@ -89,6 +89,8 @@ github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
github.com/docker/docker v28.3.3+incompatible h1:Dypm25kh4rmk49v1eiVbsAtpAsYURjYkaKubwuBdxEI=
github.com/docker/docker v28.3.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v28.4.0+incompatible h1:KVC7bz5zJY/4AZe/78BIvCnPsLaC9T/zh72xnlrTTOk=
github.com/docker/docker v28.4.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94=
github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=