packer: Environment.Cli error tests

This commit is contained in:
Mitchell Hashimoto 2013-05-07 20:50:22 -07:00
parent de444867d3
commit cbab761ab1
1 changed files with 12 additions and 0 deletions

View File

@ -93,6 +93,18 @@ func TestEnvironment_Builder_Error(t *testing.T) {
assert.Nil(returnedBuilder, "should be no builder")
}
func TestEnvironment_Cli_Error(t *testing.T) {
assert := asserts.NewTestingAsserts(t, true)
config := DefaultEnvironmentConfig()
config.CommandFunc = func(n string) (Command, error) { return nil, errors.New("foo") }
env, _ := NewEnvironment(config)
_, err := env.Cli([]string{"foo"})
assert.NotNil(err, "should be an error")
assert.Equal(err.Error(), "foo", "should be correct error")
}
func TestEnvironment_Cli_CallsRun(t *testing.T) {
assert := asserts.NewTestingAsserts(t, true)