From 62ea1d2d00f1ddbd22157a2bdce78a9b11dd4919 Mon Sep 17 00:00:00 2001 From: Justin Alvarez Date: Fri, 29 Sep 2023 12:43:52 -0400 Subject: [PATCH] fix linting issues Signed-off-by: Justin Alvarez --- cmd/finch/nerdctl_windows_test.go | 49 ++++++++++--------------------- pkg/path/finch_test.go | 1 - 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/cmd/finch/nerdctl_windows_test.go b/cmd/finch/nerdctl_windows_test.go index e354b7513..65d29351b 100644 --- a/cmd/finch/nerdctl_windows_test.go +++ b/cmd/finch/nerdctl_windows_test.go @@ -120,8 +120,7 @@ func TestNerdctlCommand_run(t *testing.T) { c := mocks.NewCommand(ctrl) // alias substitution, build => image build - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "image", "build", "-t", "demo", "/mnt/c/Users").Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "image", "build", "-t", "demo", "/mnt/c/Users").Return(c) c.EXPECT().Run() }, }, @@ -257,9 +256,8 @@ func TestNerdctlCommand_run(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) ncsd.EXPECT().FilePathToSlash(augmentedPath).Return(wslPath) lcc.EXPECT(). - Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", - nerdctlCmdName, "container", "run", "-e", "ARG1=val1", "--rm", "alpine:latest", "env").Return(c) - + Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "-e", "ARG1=val1", "--rm", "alpine:latest", "env"). + Return(c) c.EXPECT().Run() }, }, @@ -295,8 +293,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) ncsd.EXPECT().FilePathToSlash(augmentedPath).Return(wslPath) lcc.EXPECT(). - Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", - nerdctlCmdName, "container", "run", "-e", "ARG2=val2", "--rm", "alpine:latest", "env"). + Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "-e", "ARG2=val2", "--rm", "alpine:latest", "env"). Return(c) c.EXPECT().Run() }, @@ -539,8 +536,7 @@ func TestNerdctlCommand_run(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir").Return(augmentedPath) ncsd.EXPECT().FilePathToSlash(augmentedPath).Return(wslPath) lcc.EXPECT().RunWithReplacingStdout( - testStdoutRs, "shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "pull", "test:tag", "--help").Return(nil) + testStdoutRs, "shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "pull", "test:tag", "--help").Return(nil) }, }, { @@ -741,8 +737,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { c := mocks.NewCommand(ctrl) // alias substitution, run => container run - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", ContainsStr("src=/mnt/c/workdir"), "alpine:latest").Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", ContainsStr("src=/mnt/c/workdir"), "alpine:latest").Return(c) c.EXPECT().Run() }, }, @@ -774,8 +769,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { c := mocks.NewCommand(ctrl) // alias substitution, run => container run - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", ContainsStr("source=/mnt/c/workdir"), "alpine:latest").Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", ContainsStr("source=/mnt/c/workdir"), "alpine:latest").Return(c) c.EXPECT().Run() }, }, @@ -807,8 +801,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { c := mocks.NewCommand(ctrl) // alias substitution, run => container run - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "container", "run", ContainsStr("source=/mnt/c/workdir"), "alpine:latest").Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", ContainsStr("source=/mnt/c/workdir"), "alpine:latest").Return(c) c.EXPECT().Run() }, }, @@ -840,8 +833,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { c := mocks.NewCommand(ctrl) // alias substitution, run => container run - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", ContainsStr("source=something"), "alpine:latest").Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", ContainsStr("source=something"), "alpine:latest").Return(c) c.EXPECT().Run() }, }, @@ -873,9 +865,7 @@ func TestNerdctlCommand_Run_withBindMounts(t *testing.T) { c := mocks.NewCommand(ctrl) // alias substitution, run => container run - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", - "type=notbind,source=C:/workdir,target=/app", "alpine:latest").Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run", "--mount", "type=notbind,source=C:/workdir,target=/app", "alpine:latest").Return(c) c.EXPECT().Run() }, }, @@ -930,8 +920,7 @@ func TestNerdctlCommand_run_CpCommand(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir\\test").Return(hostcopyPath) ncsd.EXPECT().FilePathToSlash(hostcopyPath).Return(wslcopyPath) c := mocks.NewCommand(ctrl) - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "container", "cp", wslcopyPath, "somecontainer:/tmp").Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "cp", wslcopyPath, "somecontainer:/tmp").Return(c) c.EXPECT().Run() }, }, @@ -957,8 +946,7 @@ func TestNerdctlCommand_run_CpCommand(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir\\test").Return(hostcopyPath) ncsd.EXPECT().FilePathToSlash(hostcopyPath).Return(wslcopyPath) c := mocks.NewCommand(ctrl) - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "container", "cp", "somecontainer:/tmp/test", wslcopyPath).Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "cp", "somecontainer:/tmp/test", wslcopyPath).Return(c) c.EXPECT().Run() }, }, @@ -984,8 +972,7 @@ func TestNerdctlCommand_run_CpCommand(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir\\test").Return(hostcopyPath) ncsd.EXPECT().FilePathToSlash(hostcopyPath).Return(wslcopyPath) c := mocks.NewCommand(ctrl) - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "container", "cp", "-L", "somecontainer:/tmp/test", wslcopyPath).Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "cp", "-L", "somecontainer:/tmp/test", wslcopyPath).Return(c) c.EXPECT().Run() }, }, @@ -1044,8 +1031,7 @@ func TestNerdctlCommand_run_BuildCommand(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir\\buildcontext").Return(buildContext) ncsd.EXPECT().FilePathToSlash(buildContext).Return(wslBuildContextPath) c := mocks.NewCommand(ctrl) - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "image", "build", wslBuildContextPath).Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "image", "build", wslBuildContextPath).Return(c) c.EXPECT().Run() }, }, @@ -1071,8 +1057,7 @@ func TestNerdctlCommand_run_BuildCommand(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir\\buildcontext").Return(buildContext).Times(2) ncsd.EXPECT().FilePathToSlash(buildContext).Return(wslBuildContextPath).Times(2) c := mocks.NewCommand(ctrl) - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "image", "build", "-f", wslBuildContextPath, wslBuildContextPath).Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "image", "build", "-f", wslBuildContextPath, wslBuildContextPath).Return(c) c.EXPECT().Run() }, }, @@ -1102,9 +1087,7 @@ func TestNerdctlCommand_run_BuildCommand(t *testing.T) { ncsd.EXPECT().FilePathJoin(string(filepath.Separator), "mnt", "c", "workdir\\secret").Return(secretPath) ncsd.EXPECT().FilePathToSlash(secretPath).Return(wslSecretPath) c := mocks.NewCommand(ctrl) - lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, - "sudo", "-E", nerdctlCmdName, "image", "build", "--secret", - fmt.Sprintf("src=%s", wslSecretPath), wslBuildContextPath).Return(c) + lcc.EXPECT().Create("shell", "--workdir", wslPath, limaInstanceName, "sudo", "-E", nerdctlCmdName, "image", "build", "--secret", fmt.Sprintf("src=%s", wslSecretPath), wslBuildContextPath).Return(c) c.EXPECT().Run() }, }, diff --git a/pkg/path/finch_test.go b/pkg/path/finch_test.go index bc508ce0a..81b541bab 100644 --- a/pkg/path/finch_test.go +++ b/pkg/path/finch_test.go @@ -33,7 +33,6 @@ func TestFinch_UserDataDiskPath(t *testing.T) { assert.Equal(t, res, filepath.Join("homeDir", ".finch", ".disks", mockFinch.generatePathSum()+".vhdx")) } else { assert.Equal(t, res, filepath.Join("homeDir", ".finch", ".disks", mockFinch.generatePathSum())) - } }