Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Alvarez <[email protected]>
  • Loading branch information
pendo324 committed Oct 3, 2023
1 parent c341a95 commit 62ea1d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 34 deletions.
49 changes: 16 additions & 33 deletions cmd/finch/nerdctl_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
Expand Down Expand Up @@ -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)
},
},
{
Expand Down Expand Up @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
},
Expand All @@ -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()
},
},
Expand All @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
},
Expand All @@ -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()
},
},
Expand Down Expand Up @@ -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()
},
},
Expand Down
1 change: 0 additions & 1 deletion pkg/path/finch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))

}
}

Expand Down

0 comments on commit 62ea1d2

Please sign in to comment.