MCPcopy Index your code
hub / github.com/coder/coder / TestWrapDockerExec

Function TestWrapDockerExec

agent/agentcontainers/containers_internal_test.go:16–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestWrapDockerExec(t *testing.T) {
17 t.Parallel()
18 tests := []struct {
19 name string
20 containerUser string
21 cmdArgs []string
22 wantCmd []string
23 }{
24 {
25 name: "cmd with no args",
26 containerUser: "my-user",
27 cmdArgs: []string{"my-cmd"},
28 wantCmd: []string{"docker", "exec", "--interactive", "--user", "my-user", "my-container", "my-cmd"},
29 },
30 {
31 name: "cmd with args",
32 containerUser: "my-user",
33 cmdArgs: []string{"my-cmd", "arg1", "--arg2", "arg3", "--arg4"},
34 wantCmd: []string{"docker", "exec", "--interactive", "--user", "my-user", "my-container", "my-cmd", "arg1", "--arg2", "arg3", "--arg4"},
35 },
36 {
37 name: "no user specified",
38 containerUser: "",
39 cmdArgs: []string{"my-cmd"},
40 wantCmd: []string{"docker", "exec", "--interactive", "my-container", "my-cmd"},
41 },
42 }
43 for _, tt := range tests {
44 t.Run(tt.name, func(t *testing.T) {
45 t.Parallel()
46 actualCmd, actualArgs := wrapDockerExec("my-container", tt.containerUser, tt.cmdArgs[0], tt.cmdArgs[1:]...)
47 assert.Equal(t, tt.wantCmd[0], actualCmd)
48 assert.Equal(t, tt.wantCmd[1:], actualArgs)
49 })
50 }
51}
52
53func TestConvertDockerPort(t *testing.T) {
54 t.Parallel()

Callers

nothing calls this directly

Calls 3

wrapDockerExecFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected