Skip to content

Commit 305c048

Browse files
committed
cli/command/container/opts_test: add entrypoint slice tests
Signed-off-by: Lalyos Papp <lalyos@yahoo.com>
1 parent 32a8223 commit 305c048

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

cli/command/container/opts_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,47 @@ func TestParseEntryPoint(t *testing.T) {
10201020
assert.Check(t, is.DeepEqual([]string(config.Entrypoint), []string{"anything"}))
10211021
}
10221022

1023+
func TestParseEntryPointSlice(t *testing.T) {
1024+
testCases := []struct {
1025+
name string
1026+
input string
1027+
expected []string
1028+
}{
1029+
{
1030+
name: "nothing",
1031+
input: "",
1032+
expected: nil,
1033+
},
1034+
{
1035+
name: "empty list",
1036+
input: "--entrypoint=[]",
1037+
expected: []string{},
1038+
},
1039+
{
1040+
name: "empty string",
1041+
input: "--entrypoint=",
1042+
expected: []string{""},
1043+
},
1044+
{
1045+
name: "single",
1046+
input: `--entrypoint=["something"]`,
1047+
expected: []string{"something"},
1048+
},
1049+
{
1050+
name: "multiple",
1051+
input: `--entrypoint=["sh","-c","echo foo bar"]`,
1052+
expected: []string{"sh", "-c", "echo foo bar"},
1053+
},
1054+
}
1055+
for _, tc := range testCases {
1056+
t.Run(tc.name, func(t *testing.T) {
1057+
config, _, _, err := parseRun([]string{tc.input})
1058+
assert.NilError(t, err)
1059+
assert.Check(t, is.DeepEqual([]string(config.Entrypoint), tc.expected))
1060+
})
1061+
}
1062+
}
1063+
10231064
func TestValidateDevice(t *testing.T) {
10241065
skip.If(t, runtime.GOOS != "linux") // Windows and macOS validate server-side
10251066
valid := []string{

0 commit comments

Comments
 (0)