From fed77746f6bb68fa7cde9a4113151c38e38b22de Mon Sep 17 00:00:00 2001 From: Simon Aronsson Date: Wed, 26 Jul 2023 14:40:26 +0200 Subject: [PATCH] test alias purging --- pkg/container/client_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/container/client_test.go b/pkg/container/client_test.go index 24c3222..6600123 100644 --- a/pkg/container/client_test.go +++ b/pkg/container/client_test.go @@ -1,6 +1,7 @@ package container import ( + "github.com/docker/docker/api/types/network" "time" "github.com/containrrr/watchtower/internal/util" @@ -284,6 +285,24 @@ var _ = Describe("the client", func() { }) }) }) + Describe(`GetNetworkConfig`, func() { + When(`providing a container with network aliases`, func() { + It(`should purge the aliases`, func() { + aliases := []string{"One", "Two"} + client := dockerClient{ + api: docker, + ClientOptions: ClientOptions{PullImages: false, IncludeRestarting: false}, + } + container := MockContainer(WithImageName("docker.io/prefix/imagename:latest")) + endpoints := map[string]*network.EndpointSettings{ + `test`: {Aliases: aliases}, + } + container.containerInfo.NetworkSettings = &types.NetworkSettings{Networks: endpoints} + Expect(container.ContainerInfo().NetworkSettings.Networks[`test`].Aliases).To(Equal(aliases)) + Expect(client.GetNetworkConfig(container).EndpointsConfig[`test`].Aliases).To(BeEmpty()) + }) + }) + }) }) // Capture logrus output in buffer