2016-03-04 02:14:55 -08:00
|
|
|
package arm
|
|
|
|
|
|
|
|
import (
|
2016-04-21 16:50:03 -07:00
|
|
|
"testing"
|
2016-07-29 14:17:33 -07:00
|
|
|
|
2017-04-04 13:39:01 -07:00
|
|
|
"github.com/hashicorp/packer/builder/azure/common/constants"
|
2016-03-04 02:14:55 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestStateBagShouldBePopulatedExpectedValues(t *testing.T) {
|
2019-12-17 11:25:56 +01:00
|
|
|
var testSubject Builder
|
2019-12-16 21:23:05 -08:00
|
|
|
_, _, err := testSubject.Prepare(getArmBuilderConfiguration(), getPackerConfiguration())
|
2016-04-21 16:50:03 -07:00
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to prepare: %s", err)
|
|
|
|
}
|
2016-03-04 02:14:55 -08:00
|
|
|
|
|
|
|
var expectedStateBagKeys = []string{
|
|
|
|
constants.AuthorizedKey,
|
|
|
|
|
2016-07-29 14:17:33 -07:00
|
|
|
constants.ArmTags,
|
2016-03-04 02:14:55 -08:00
|
|
|
constants.ArmComputeName,
|
|
|
|
constants.ArmDeploymentName,
|
2016-06-30 16:51:52 -07:00
|
|
|
constants.ArmNicName,
|
2016-03-04 02:14:55 -08:00
|
|
|
constants.ArmResourceGroupName,
|
2016-04-21 16:50:03 -07:00
|
|
|
constants.ArmStorageAccountName,
|
2016-03-04 02:14:55 -08:00
|
|
|
constants.ArmVirtualMachineCaptureParameters,
|
|
|
|
constants.ArmPublicIPAddressName,
|
2018-05-15 11:41:26 -07:00
|
|
|
constants.ArmAsyncResourceGroupDelete,
|
2016-03-04 02:14:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, v := range expectedStateBagKeys {
|
|
|
|
if _, ok := testSubject.stateBag.GetOk(v); ok == false {
|
|
|
|
t.Errorf("Expected the builder's state bag to contain '%s', but it did not.", v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|