(t *testing.T)
| 137 | } |
| 138 | |
| 139 | func Test_parseFields_errors(t *testing.T) { |
| 140 | ios, stdin, _, _ := iostreams.Test() |
| 141 | fmt.Fprint(stdin, "pasted contents") |
| 142 | |
| 143 | tests := []struct { |
| 144 | name string |
| 145 | opts *ApiOptions |
| 146 | expected string |
| 147 | }{ |
| 148 | { |
| 149 | name: "cannot overwrite string to array", |
| 150 | opts: &ApiOptions{ |
| 151 | IO: ios, |
| 152 | RawFields: []string{ |
| 153 | "object[field]=A", |
| 154 | "object[field][]=this should be an error", |
| 155 | }, |
| 156 | }, |
| 157 | expected: `expected array type under "field", got string`, |
| 158 | }, |
| 159 | { |
| 160 | name: "cannot overwrite string to object", |
| 161 | opts: &ApiOptions{ |
| 162 | IO: ios, |
| 163 | RawFields: []string{ |
| 164 | "object[field]=B", |
| 165 | "object[field][field2]=this should be an error", |
| 166 | }, |
| 167 | }, |
| 168 | expected: `expected map type under "field", got string`, |
| 169 | }, |
| 170 | { |
| 171 | name: "cannot overwrite object to string", |
| 172 | opts: &ApiOptions{ |
| 173 | IO: ios, |
| 174 | RawFields: []string{ |
| 175 | "object[field][field2]=C", |
| 176 | "object[field]=this should be an error", |
| 177 | }, |
| 178 | }, |
| 179 | expected: `unexpected override existing field under "field"`, |
| 180 | }, |
| 181 | { |
| 182 | name: "cannot overwrite object to array", |
| 183 | opts: &ApiOptions{ |
| 184 | IO: ios, |
| 185 | RawFields: []string{ |
| 186 | "object[field][field2]=D", |
| 187 | "object[field][]=this should be an error", |
| 188 | }, |
| 189 | }, |
| 190 | expected: `expected array type under "field", got map[string]interface {}`, |
| 191 | }, |
| 192 | { |
| 193 | name: "cannot overwrite array to string", |
| 194 | opts: &ApiOptions{ |
| 195 | IO: ios, |
| 196 | RawFields: []string{ |
nothing calls this directly
no test coverage detected