Testing the new options argument during the actual

call to `Provision()`
This commit is contained in:
Trevor Suarez 2015-11-03 14:59:55 -05:00
parent 84e1b387c4
commit 4ea7e3473d
1 changed files with 32 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package puppetmasterless
import (
"io/ioutil"
"os"
"strings"
"testing"
"github.com/mitchellh/packer/packer"
@ -207,3 +208,34 @@ func TestProvisionerPrepare_options(t *testing.T) {
t.Fatalf("err: %s", err)
}
}
func TestProvisionerProvision_options(t *testing.T) {
config := testConfig()
ui := &packer.MachineReadableUi{
Writer: ioutil.Discard,
}
comm := new(packer.MockCommunicator)
options := []string{
"--some-arg=yup",
"--some-other-arg",
}
config["options"] = options
p := new(Provisioner)
err := p.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
err = p.Provision(ui, comm)
if err != nil {
t.Fatalf("err: %s", err)
}
expectedArgs := strings.Join(options, " ")
if !strings.Contains(comm.StartCmd.Command, expectedArgs) {
t.Fatalf("Command %q doesn't contain the expected arguments %q", comm.StartCmd.Command, expectedArgs)
}
}