From b711372cab3efae6bc59bc735be6d38689ec33e0 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 3 Jul 2024 16:29:16 +0200 Subject: [PATCH] cli/command/container: TestNewAttachCommandErrors: use struct-literals Signed-off-by: Sebastiaan van Stijn --- cli/command/container/attach_test.go | 43 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/cli/command/container/attach_test.go b/cli/command/container/attach_test.go index 7c16aec778..11f4ced45f 100644 --- a/cli/command/container/attach_test.go +++ b/cli/command/container/attach_test.go @@ -32,10 +32,13 @@ func TestNewAttachCommandErrors(t *testing.T) { args: []string{"5cb5bb5e4a3b"}, expectedError: "You cannot attach to a stopped container", containerInspectFunc: func(containerID string) (types.ContainerJSON, error) { - c := types.ContainerJSON{} - c.ContainerJSONBase = &types.ContainerJSONBase{} - c.ContainerJSONBase.State = &types.ContainerState{Running: false} - return c, nil + return types.ContainerJSON{ + ContainerJSONBase: &types.ContainerJSONBase{ + State: &types.ContainerState{ + Running: false, + }, + }, + }, nil }, }, { @@ -43,13 +46,14 @@ func TestNewAttachCommandErrors(t *testing.T) { args: []string{"5cb5bb5e4a3b"}, expectedError: "You cannot attach to a paused container", containerInspectFunc: func(containerID string) (types.ContainerJSON, error) { - c := types.ContainerJSON{} - c.ContainerJSONBase = &types.ContainerJSONBase{} - c.ContainerJSONBase.State = &types.ContainerState{ - Running: true, - Paused: true, - } - return c, nil + return types.ContainerJSON{ + ContainerJSONBase: &types.ContainerJSONBase{ + State: &types.ContainerState{ + Running: true, + Paused: true, + }, + }, + }, nil }, }, { @@ -57,14 +61,15 @@ func TestNewAttachCommandErrors(t *testing.T) { args: []string{"5cb5bb5e4a3b"}, expectedError: "You cannot attach to a restarting container", containerInspectFunc: func(containerID string) (types.ContainerJSON, error) { - c := types.ContainerJSON{} - c.ContainerJSONBase = &types.ContainerJSONBase{} - c.ContainerJSONBase.State = &types.ContainerState{ - Running: true, - Paused: false, - Restarting: true, - } - return c, nil + return types.ContainerJSON{ + ContainerJSONBase: &types.ContainerJSONBase{ + State: &types.ContainerState{ + Running: true, + Paused: false, + Restarting: true, + }, + }, + }, nil }, }, }