packer-cn/provisioner/shell-local/provisioner_test.go
Megan Marsh a0edaf6c46 Going to revert this change for now, becuase of potential issues that arise from calling Prepare() twice
Revert "use statebag instead of SetSharedState for winRM password"

This reverts commit b35acbd8798a1baa645f0d181731a9cd9318a61c.
2018-09-10 16:48:42 -07:00

68 lines
979 B
Go

package shell
import (
"testing"
"github.com/hashicorp/packer/packer"
)
func TestProvisioner_impl(t *testing.T) {
var _ packer.Provisioner = new(Provisioner)
}
func TestConfigPrepare(t *testing.T) {
cases := []struct {
Key string
Value interface{}
Err bool
}{
{
"unknown_key",
"bad",
true,
},
{
"command",
nil,
true,
},
}
for _, tc := range cases {
raw := testConfig(t)
if tc.Value == nil {
delete(raw, tc.Key)
} else {
raw[tc.Key] = tc.Value
}
var p Provisioner
err := p.Prepare(raw)
if tc.Err {
testConfigErr(t, err, tc.Key)
} else {
testConfigOk(t, err)
}
}
}
func testConfig(t *testing.T) map[string]interface{} {
return map[string]interface{}{
"command": "echo foo",
}
}
func testConfigErr(t *testing.T, err error, extra string) {
if err == nil {
t.Fatalf("should error: %s", extra)
}
}
func testConfigOk(t *testing.T, err error) {
if err != nil {
t.Fatalf("bad: %s", err)
}
}