From 109be6b5e325d89ba7f657a74625e6cab86e7bcf Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 20 Apr 2013 18:22:27 -0600 Subject: [PATCH] Better testing of CLI --- packer/environment_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packer/environment_test.go b/packer/environment_test.go index 995e6ec38..5c171d682 100644 --- a/packer/environment_test.go +++ b/packer/environment_test.go @@ -8,11 +8,15 @@ import ( ) type TestCommand struct { + runArgs []string runCalled bool + runEnv *Environment } func (tc *TestCommand) Run(env *Environment, args []string) int { tc.runCalled = true + tc.runArgs = args + tc.runEnv = env return 0 } @@ -40,8 +44,10 @@ func TestEnvironment_Cli_CallsRun(t *testing.T) { config.Command["foo"] = command env := NewEnvironment(config) - assert.Equal(env.Cli([]string{"foo"}), 0, "runs foo command") + assert.Equal(env.Cli([]string{"foo", "bar", "baz"}), 0, "runs foo command") assert.True(command.runCalled, "run should've been called") + assert.Equal(command.runEnv, env, "should've ran with env") + assert.Equal(command.runArgs, []string{"bar", "baz"}, "should have right args") } func TestEnvironment_DefaultCli_Empty(t *testing.T) {