Skip to content

Commit

Permalink
cli/command/container/opts_test: add entrypoint slice tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lalyos Papp <[email protected]>
  • Loading branch information
lalyos committed Feb 18, 2025
1 parent 32a8223 commit c01df63
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions cli/command/container/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,47 @@ func TestParseEntryPoint(t *testing.T) {
assert.Check(t, is.DeepEqual([]string(config.Entrypoint), []string{"anything"}))
}

func TestParseEntryPointSlice(t *testing.T) {
testCases := []struct {
name string
input string
expected []string
}{
{
name: "nothing",
input: "",
expected: nil,
},
{
name: "empty list",
input: "--entrypoint=[]",
expected: []string{},
},
{
name: "empty string",
input: "--entrypoint=",
expected: []string{""},
},
{
name: "single",
input: `--entrypoint=["something"]`,
expected: []string{"something"},
},
{
name: "multiple",
input: `--entrypoint=["sh","-c","echo foo bar"]`,
expected: []string{"sh", "-c", "echo foo bar"},
},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("%s", tc.name), func(t *testing.T) {
config, _, _, err := parseRun([]string{tc.input})
assert.NilError(t, err)
assert.Check(t, is.DeepEqual([]string(config.Entrypoint), tc.expected))
})
}
}

func TestValidateDevice(t *testing.T) {
skip.If(t, runtime.GOOS != "linux") // Windows and macOS validate server-side
valid := []string{
Expand Down

0 comments on commit c01df63

Please sign in to comment.