(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func 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 | |
| 53 | func TestConvertDockerPort(t *testing.T) { |
| 54 | t.Parallel() |
nothing calls this directly
no test coverage detected