From cbab761ab1d9e003af195c477840cc9f8a1bb454 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 7 May 2013 20:50:22 -0700 Subject: [PATCH] packer: Environment.Cli error tests --- packer/environment_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packer/environment_test.go b/packer/environment_test.go index 6870d25a0..2f16b4090 100644 --- a/packer/environment_test.go +++ b/packer/environment_test.go @@ -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)