2016-03-04 05:14:55 -05:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
2016-05-06 23:32:18 -04:00
|
|
|
// Licensed under the MIT License. See the LICENSE file in builder/azure for license information.
|
2016-03-04 05:14:55 -05:00
|
|
|
|
|
|
|
package arm
|
|
|
|
|
|
|
|
import (
|
2016-04-21 19:50:03 -04:00
|
|
|
"testing"
|
2016-07-29 17:17:33 -04:00
|
|
|
|
|
|
|
"github.com/mitchellh/packer/builder/azure/common/constants"
|
2016-03-04 05:14:55 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestStateBagShouldBePopulatedExpectedValues(t *testing.T) {
|
|
|
|
var testSubject = &Builder{}
|
2016-04-21 19:50:03 -04:00
|
|
|
_, err := testSubject.Prepare(getArmBuilderConfiguration(), getPackerConfiguration())
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("failed to prepare: %s", err)
|
|
|
|
}
|
2016-03-04 05:14:55 -05:00
|
|
|
|
|
|
|
var expectedStateBagKeys = []string{
|
|
|
|
constants.AuthorizedKey,
|
|
|
|
constants.PrivateKey,
|
|
|
|
|
2016-07-29 17:17:33 -04:00
|
|
|
constants.ArmTags,
|
2016-03-04 05:14:55 -05:00
|
|
|
constants.ArmComputeName,
|
|
|
|
constants.ArmDeploymentName,
|
|
|
|
constants.ArmLocation,
|
2016-06-30 19:51:52 -04:00
|
|
|
constants.ArmNicName,
|
2016-03-04 05:14:55 -05:00
|
|
|
constants.ArmResourceGroupName,
|
2016-04-21 19:50:03 -04:00
|
|
|
constants.ArmStorageAccountName,
|
2016-03-04 05:14:55 -05:00
|
|
|
constants.ArmVirtualMachineCaptureParameters,
|
|
|
|
constants.ArmPublicIPAddressName,
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|