(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestParseShellArgs(t *testing.T) { |
| 21 | tests := []struct { |
| 22 | name string |
| 23 | input string |
| 24 | want []string |
| 25 | }{ |
| 26 | { |
| 27 | name: "plain args", |
| 28 | input: "ls -l -p /Movies", |
| 29 | want: []string{"ls", "-l", "-p", "/Movies"}, |
| 30 | }, |
| 31 | { |
| 32 | name: "double quoted path", |
| 33 | input: `cd "/Movies/Kids Cartoons"`, |
| 34 | want: []string{"cd", "/Movies/Kids Cartoons"}, |
| 35 | }, |
| 36 | { |
| 37 | name: "single quoted path", |
| 38 | input: "cd '/Movies/Kids Cartoons'", |
| 39 | want: []string{"cd", "/Movies/Kids Cartoons"}, |
| 40 | }, |
| 41 | { |
| 42 | name: "escaped spaces", |
| 43 | input: `cd /My\ Pack/Kids\ Cartoons`, |
| 44 | want: []string{"cd", "/My Pack/Kids Cartoons"}, |
| 45 | }, |
| 46 | } |
| 47 | |
| 48 | for _, tt := range tests { |
| 49 | t.Run(tt.name, func(t *testing.T) { |
| 50 | require.Equal(t, tt.want, parseShellArgs(tt.input)) |
| 51 | }) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func TestResolveShellPath(t *testing.T) { |
| 56 | tests := []struct { |
nothing calls this directly
no test coverage detected