| 9 | ) |
| 10 | |
| 11 | func TestParseURL(t *testing.T) { |
| 12 | testCases := []struct { |
| 13 | doc string |
| 14 | url string |
| 15 | remoteCommand []string |
| 16 | expectedArgs []string |
| 17 | expectedError string |
| 18 | expectedSpec Spec |
| 19 | }{ |
| 20 | { |
| 21 | doc: "bare ssh URL", |
| 22 | url: "ssh://example.com", |
| 23 | expectedArgs: []string{ |
| 24 | "--", "example.com", |
| 25 | }, |
| 26 | expectedSpec: Spec{ |
| 27 | Host: "example.com", |
| 28 | }, |
| 29 | }, |
| 30 | { |
| 31 | doc: "bare ssh URL with trailing slash", |
| 32 | url: "ssh://example.com/", |
| 33 | expectedArgs: []string{ |
| 34 | "--", "example.com", |
| 35 | }, |
| 36 | expectedSpec: Spec{ |
| 37 | Host: "example.com", |
| 38 | Path: "/", |
| 39 | }, |
| 40 | }, |
| 41 | { |
| 42 | doc: "bare ssh URL with trailing slashes", |
| 43 | url: "ssh://example.com//", |
| 44 | expectedArgs: []string{ |
| 45 | "--", "example.com", |
| 46 | }, |
| 47 | expectedSpec: Spec{ |
| 48 | Host: "example.com", |
| 49 | Path: "//", |
| 50 | }, |
| 51 | }, |
| 52 | { |
| 53 | doc: "bare ssh URL and remote command", |
| 54 | url: "ssh://example.com", |
| 55 | remoteCommand: []string{ |
| 56 | "docker", "system", "dial-stdio", |
| 57 | }, |
| 58 | expectedArgs: []string{ |
| 59 | "--", "example.com", |
| 60 | `docker system dial-stdio`, |
| 61 | }, |
| 62 | expectedSpec: Spec{ |
| 63 | Host: "example.com", |
| 64 | }, |
| 65 | }, |
| 66 | { |
| 67 | doc: "ssh URL with path and remote command and flag", |
| 68 | url: "ssh://example.com/var/run/docker.sock", |