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