| 26 | ) |
| 27 | |
| 28 | func Test_convert(t *testing.T) { |
| 29 | tests := []struct { |
| 30 | name string |
| 31 | args []string |
| 32 | want []string |
| 33 | wantErr bool |
| 34 | }{ |
| 35 | { |
| 36 | name: "compose only", |
| 37 | args: []string{"up"}, |
| 38 | want: []string{"compose", "up"}, |
| 39 | }, |
| 40 | { |
| 41 | name: "with context", |
| 42 | args: []string{"--context", "foo", "-f", "compose.yaml", "up"}, |
| 43 | want: []string{"--context", "foo", "compose", "-f", "compose.yaml", "up"}, |
| 44 | }, |
| 45 | { |
| 46 | name: "with context arg", |
| 47 | args: []string{"--context=foo", "-f", "compose.yaml", "up"}, |
| 48 | want: []string{"--context", "foo", "compose", "-f", "compose.yaml", "up"}, |
| 49 | }, |
| 50 | { |
| 51 | name: "with host", |
| 52 | args: []string{"--host", "tcp://1.2.3.4", "up"}, |
| 53 | want: []string{"--host", "tcp://1.2.3.4", "compose", "up"}, |
| 54 | }, |
| 55 | { |
| 56 | name: "compose --verbose", |
| 57 | args: []string{"--verbose"}, |
| 58 | want: []string{"--debug", "compose"}, |
| 59 | }, |
| 60 | { |
| 61 | name: "compose --version", |
| 62 | args: []string{"--version"}, |
| 63 | want: []string{"compose", "version"}, |
| 64 | }, |
| 65 | { |
| 66 | name: "compose -v", |
| 67 | args: []string{"-v"}, |
| 68 | want: []string{"compose", "version"}, |
| 69 | }, |
| 70 | { |
| 71 | name: "help", |
| 72 | args: []string{"-h"}, |
| 73 | want: []string{"compose", "--help"}, |
| 74 | }, |
| 75 | { |
| 76 | name: "issues/1962", |
| 77 | args: []string{"psql", "-h", "postgres"}, |
| 78 | want: []string{"compose", "psql", "-h", "postgres"}, // -h should not be converted to --help |
| 79 | }, |
| 80 | { |
| 81 | name: "issues/8648", |
| 82 | args: []string{"exec", "mongo", "mongo", "--host", "mongo"}, |
| 83 | want: []string{"compose", "exec", "mongo", "mongo", "--host", "mongo"}, // --host is passed to exec |
| 84 | }, |
| 85 | { |