(t *testing.T)
| 1334 | } |
| 1335 | |
| 1336 | func TestProcessOptionError(t *testing.T) { |
| 1337 | var testCases = []struct { |
| 1338 | name string |
| 1339 | command Cmder |
| 1340 | errorMsg string |
| 1341 | }{ |
| 1342 | { |
| 1343 | name: "OptionContainerNotEnoughArgs", |
| 1344 | command: &simpleCmd{ |
| 1345 | cmd: "option", |
| 1346 | args: []string{ |
| 1347 | "--container", |
| 1348 | }, |
| 1349 | }, |
| 1350 | errorMsg: "container: not enough arguments", |
| 1351 | }, |
| 1352 | { |
| 1353 | name: "OptionExtensionNotEnoughArgs", |
| 1354 | command: &simpleCmd{ |
| 1355 | cmd: "option", |
| 1356 | args: []string{ |
| 1357 | "--extension", |
| 1358 | }, |
| 1359 | }, |
| 1360 | errorMsg: "extension: not enough arguments", |
| 1361 | }, |
| 1362 | { |
| 1363 | name: "OptionExtensionInvalid", |
| 1364 | command: &simpleCmd{ |
| 1365 | cmd: "option", |
| 1366 | args: []string{ |
| 1367 | "--extension", |
| 1368 | "'bogus'", |
| 1369 | }, |
| 1370 | }, |
| 1371 | errorMsg: "extension: unknown option: 'bogus'. Available options are: ['all', 'bindings', 'encoders', 'lists', 'math', 'optional', 'protos', 'sets', 'strings', 'two_var_comprehensions']", |
| 1372 | }, |
| 1373 | } |
| 1374 | |
| 1375 | for _, tc := range testCases { |
| 1376 | t.Run(tc.name, func(t *testing.T) { |
| 1377 | eval, err := NewEvaluator() |
| 1378 | if err != nil { |
| 1379 | t.Fatalf("NewEvaluator returned error: %v, wanted nil", err) |
| 1380 | } |
| 1381 | _, _, err = eval.Process(tc.command) |
| 1382 | |
| 1383 | if err == nil { |
| 1384 | t.Fatalf("Expected an error processing command: %s", tc.command) |
| 1385 | } |
| 1386 | |
| 1387 | if err.Error() != tc.errorMsg { |
| 1388 | t.Errorf("For command %s got (error: '%s') wanted (error: '%s')", |
| 1389 | tc.command, err.Error(), tc.errorMsg) |
| 1390 | } |
| 1391 | }) |
| 1392 | } |
| 1393 | } |
nothing calls this directly
no test coverage detected