Skip to content

Commit 8b0dc26

Browse files
committed
chore: add longform boolean unit tests
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 3a81c08 commit 8b0dc26

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

cmd/finch/nerdctl_darwin_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,36 @@ func TestNerdctlCommand_run(t *testing.T) {
11711171
c.EXPECT().Run()
11721172
},
11731173
},
1174+
{
1175+
name: "with long-form boolean flags",
1176+
cmdName: "run",
1177+
fc: &config.Finch{},
1178+
args: []string{
1179+
"-e", "ARG1=val1", "-p", "8080:8080",
1180+
"--name", "myContainer", "--interactive=true", "--detach", "--rm=true", "--init=false", "--privileged=false", "alpine:latest", "env",
1181+
},
1182+
wantErr: nil,
1183+
mockSvc: func(
1184+
_ *testing.T,
1185+
lcc *mocks.NerdctlCmdCreator,
1186+
_ *mocks.CommandCreator,
1187+
ncsd *mocks.NerdctlCommandSystemDeps,
1188+
logger *mocks.Logger,
1189+
ctrl *gomock.Controller,
1190+
_ afero.Fs,
1191+
) {
1192+
getVMStatusC := mocks.NewCommand(ctrl)
1193+
lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC)
1194+
getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil)
1195+
logger.EXPECT().Debugf("Status of virtual machine: %s", "Running")
1196+
AddEmptyEnvLookUps(ncsd)
1197+
c := mocks.NewCommand(ctrl)
1198+
lcc.EXPECT().Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run",
1199+
"--interactive=true", "--detach", "--privileged=false", "-p", "8080:8080", "--name", "myContainer", "--rm=true", "--init=false", "-e", "ARG1=val1",
1200+
"alpine:latest", "env").Return(c)
1201+
c.EXPECT().Run()
1202+
},
1203+
},
11741204
}
11751205

11761206
for _, tc := range testCases {

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,5 @@ require (
158158
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
159159
k8s.io/klog/v2 v2.130.1 // indirect
160160
)
161+
162+
replace github.com/runfinch/common-tests => /home/arjunry/codestation/common-tests

0 commit comments

Comments
 (0)