(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestCommandsUnmarshalString(t *testing.T) { |
| 16 | tests := []struct { |
| 17 | jsonIn string |
| 18 | want Commands |
| 19 | }{ |
| 20 | { |
| 21 | jsonIn: `null`, |
| 22 | want: Commands{ |
| 23 | MarshalAs: CmdArray, |
| 24 | Cmds: nil, |
| 25 | }, |
| 26 | }, |
| 27 | { |
| 28 | jsonIn: `""`, |
| 29 | want: Commands{ |
| 30 | MarshalAs: CmdString, |
| 31 | Cmds: []string{""}, |
| 32 | }, |
| 33 | }, |
| 34 | { |
| 35 | jsonIn: `"\n"`, |
| 36 | want: Commands{ |
| 37 | MarshalAs: CmdString, |
| 38 | Cmds: []string{"\n"}, |
| 39 | }, |
| 40 | }, |
| 41 | { |
| 42 | jsonIn: `"echo 'line1'\necho 'line2'"`, |
| 43 | want: Commands{ |
| 44 | MarshalAs: CmdString, |
| 45 | Cmds: []string{"echo 'line1'\necho 'line2'"}, |
| 46 | }, |
| 47 | }, |
| 48 | { |
| 49 | jsonIn: `"echo '\nline1'\necho 'line2'\n"`, |
| 50 | want: Commands{ |
| 51 | MarshalAs: CmdString, |
| 52 | Cmds: []string{"echo '\nline1'\necho 'line2'\n"}, |
| 53 | }, |
| 54 | }, |
| 55 | { |
| 56 | jsonIn: `"echo 'line1'\n\necho 'line2'"`, |
| 57 | want: Commands{ |
| 58 | MarshalAs: CmdString, |
| 59 | Cmds: []string{"echo 'line1'\n\necho 'line2'"}, |
| 60 | }, |
| 61 | }, |
| 62 | { |
| 63 | jsonIn: `"echo 'line1'\necho '\tline2'"`, |
| 64 | want: Commands{ |
| 65 | MarshalAs: CmdString, |
| 66 | Cmds: []string{"echo 'line1'\necho '\tline2'"}, |
| 67 | }, |
| 68 | }, |
| 69 | } |
| 70 | for _, test := range tests { |
| 71 | t.Run(test.jsonIn, func(t *testing.T) { |
| 72 | got := Commands{} |
nothing calls this directly
no test coverage detected