diff --git a/provisioner/powershell/provisioner_acc_test.go b/provisioner/powershell/provisioner_acc_test.go index 846ab0c3d..4a471082e 100644 --- a/provisioner/powershell/provisioner_acc_test.go +++ b/provisioner/powershell/provisioner_acc_test.go @@ -39,6 +39,15 @@ func TestAccPowershellProvisioner_Script(t *testing.T) { acc.TestProvisionersAgainstBuilders(&testProvisioner, t) } +func TestPowershellProvisioner_Invalid(t *testing.T) { + acc.TestProvisionersPreCheck(TestProvisionerName, t) + + // This test should fail with a non-zero exit code. To assert the failure the fixture + // uses the valid_exit_codes option to confirm a non-zero exit code + testProvisioner := PowershellProvisionerAccTest{"powershell-provisioner-invalid.txt"} + acc.TestProvisionersAgainstBuilders(&testProvisioner, t) +} + type PowershellProvisionerAccTest struct { ConfigName string } diff --git a/provisioner/powershell/test-fixtures/powershell-provisioner-invalid.txt b/provisioner/powershell/test-fixtures/powershell-provisioner-invalid.txt new file mode 100644 index 000000000..836d9c5cf --- /dev/null +++ b/provisioner/powershell/test-fixtures/powershell-provisioner-invalid.txt @@ -0,0 +1,5 @@ +{ + "type": "powershell", + "inline": "this is not a valid powershell command", + "valid_exit_codes": ["1"] +}