MCPcopy Index your code
hub / github.com/docker/cli / TestCommand

Function TestCommand

cli/connhelper/ssh/ssh_test.go:200–317  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

198}
199
200func TestCommand(t *testing.T) {
201 testCases := []struct {
202 doc string
203 url string
204 sshFlags []string
205 customCmd []string
206 expectedCmd []string
207 expectedError string
208 }{
209 {
210 doc: "bare ssh URL",
211 url: "ssh://example.com",
212 expectedCmd: []string{
213 "--", "example.com",
214 "docker system dial-stdio",
215 },
216 },
217 {
218 doc: "bare ssh URL with trailing slash",
219 url: "ssh://example.com/",
220 expectedCmd: []string{
221 "--", "example.com",
222 "docker system dial-stdio",
223 },
224 },
225 {
226 doc: "bare ssh URL with custom ssh flags",
227 url: "ssh://example.com",
228 sshFlags: []string{"-T", "-o", "ConnectTimeout=30", "-oStrictHostKeyChecking=no"},
229 expectedCmd: []string{
230 "-T",
231 "-o", "ConnectTimeout=30",
232 "-oStrictHostKeyChecking=no",
233 "--", "example.com",
234 "docker system dial-stdio",
235 },
236 },
237 {
238 doc: "ssh URL with all options",
239 url: "ssh://me@example.com:10022/var/run/docker.sock",
240 sshFlags: []string{"-T", "-o ConnectTimeout=30"},
241 expectedCmd: []string{
242 "-l", "me",
243 "-p", "10022",
244 "-T",
245 "-o ConnectTimeout=30",
246 "--", "example.com",
247 "docker '--host=unix:///var/run/docker.sock' system dial-stdio",
248 },
249 },
250 {
251 doc: "bad ssh flags",
252 url: "ssh://example.com",
253 sshFlags: []string{"-T", "-o", `ConnectTimeout=30 $(echo hi > /hi.txt)`},
254 expectedCmd: []string{
255 "-T",
256 "-o", `ConnectTimeout=30 $(echo hi > /hi.txt)`,
257 "--", "example.com",

Callers

nothing calls this directly

Calls 3

ParseURLFunction · 0.85
CommandMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…