From d9d6f794a185b625fc850ca79e5af23f5a4c2e9f Mon Sep 17 00:00:00 2001 From: "Jeremy L. Morris" Date: Fri, 12 Nov 2021 06:21:34 -0500 Subject: [PATCH] feat: use a more specific error type for no container info (#1115) Co-authored-by: Jeremy L. Morris --- pkg/container/container.go | 2 +- pkg/container/container_test.go | 2 +- pkg/container/errors.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/container/container.go b/pkg/container/container.go index 4ea3e9f..c55394a 100644 --- a/pkg/container/container.go +++ b/pkg/container/container.go @@ -285,7 +285,7 @@ func (c Container) VerifyConfiguration() error { containerInfo := c.ContainerInfo() if containerInfo == nil { - return errorInvalidConfig + return errorNoContainerInfo } containerConfig := containerInfo.Config diff --git a/pkg/container/container_test.go b/pkg/container/container_test.go index 5204f7d..08cba7a 100644 --- a/pkg/container/container_test.go +++ b/pkg/container/container_test.go @@ -23,7 +23,7 @@ var _ = Describe("the container", func() { c := mockContainerWithPortBindings() c.containerInfo = nil err := c.VerifyConfiguration() - Expect(err).To(Equal(errorInvalidConfig)) + Expect(err).To(Equal(errorNoContainerInfo)) }) }) When("verifying a container with no config", func() { diff --git a/pkg/container/errors.go b/pkg/container/errors.go index b927220..1937430 100644 --- a/pkg/container/errors.go +++ b/pkg/container/errors.go @@ -3,5 +3,6 @@ package container import "errors" var errorNoImageInfo = errors.New("no available image info") +var errorNoContainerInfo = errors.New("no available container info") var errorNoExposedPorts = errors.New("exposed ports does not match port bindings") var errorInvalidConfig = errors.New("container configuration missing or invalid")