From e155d2a1c8305018da839e9a93a4702a7b43e8ce Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 27 Mar 2020 16:45:01 -0700 Subject: [PATCH] add mock so we can test full provision flow --- provisioner/ansible/mock_ansible.go | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 provisioner/ansible/mock_ansible.go diff --git a/provisioner/ansible/mock_ansible.go b/provisioner/ansible/mock_ansible.go new file mode 100644 index 000000000..f0d1fe69a --- /dev/null +++ b/provisioner/ansible/mock_ansible.go @@ -0,0 +1,31 @@ +// +build !windows + +package ansible + +import ( + "fmt" + + "github.com/hashicorp/packer/packer" +) + +type provisionLogicTracker struct { + setupAdapterCalled bool + executeAnsibleCalled bool + happyPath bool +} + +func (l *provisionLogicTracker) setupAdapter(ui packer.Ui, comm packer.Communicator) (string, error) { + l.setupAdapterCalled = true + if l.happyPath { + return "fakeKeyString", nil + } + return "", fmt.Errorf("chose sadpath") +} + +func (l *provisionLogicTracker) executeAnsible(ui packer.Ui, comm packer.Communicator, privKeyFile string) error { + l.executeAnsibleCalled = true + if l.happyPath { + return fmt.Errorf("Chose sadpath") + } + return nil +}