Fix tests for Shared Image Gallery
This commit is contained in:
parent
a3a2a9e970
commit
c7180413b0
|
@ -1309,9 +1309,9 @@ func TestConfigShouldAllowSharedImageGalleryOptions(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
c, _, err := newConfig(config, getPackerConfiguration())
|
_, _, err := newConfig(config, getPackerConfiguration())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("expected config to accept Shared Image Gallery options", err)
|
t.Log("expected config to accept Shared Image Gallery options", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1334,9 +1334,9 @@ func TestConfigShouldRejectSharedImageGalleryWithVhdTarget(t *testing.T) {
|
||||||
"capture_name_prefix": "ignore",
|
"capture_name_prefix": "ignore",
|
||||||
}
|
}
|
||||||
|
|
||||||
c, _, err := newConfig(config, getPackerConfiguration())
|
_, _, err := newConfig(config, getPackerConfiguration())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("expected an error if Shared Image Gallery source is used with VHD target", err)
|
t.Log("expected an error if Shared Image Gallery source is used with VHD target", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,37 +183,33 @@ func TestBuildWindows02(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shared Image Gallery Build
|
// Shared Image Gallery Build
|
||||||
func TestSharedIageGallery00(t *testing.T) {
|
func TestSharedImageGallery00(t *testing.T) {
|
||||||
testSubject, err := NewTemplateBuilder(BasicTemplate)
|
testSubject, err := NewTemplateBuilder(BasicTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = testSubject.BuildLinux("--test-ssh-authorized-key--")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
imageID := "/subscriptions/ignore/resourceGroups/ignore/providers/Microsoft.Compute/galleries/ignore/images/ignore"
|
imageID := "/subscriptions/ignore/resourceGroups/ignore/providers/Microsoft.Compute/galleries/ignore/images/ignore"
|
||||||
err = testSubject.SetSharedGalleryImage("westcentralus", imageID)
|
err = testSubject.SetSharedGalleryImage("westcentralus", imageID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
doc, err := testSubject.ToJSON()
|
if (*testSubject.template.Variables)["apiVersion"] != "2018-04-01" {
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = approvaltests.VerifyJSONBytes(t, []byte(*doc))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if doc.variables.apiVersion != "2018-04-01" {
|
|
||||||
t.Fatal("ARM template for Shared Image Gallery must use apiVersion 2018-04-01")
|
t.Fatal("ARM template for Shared Image Gallery must use apiVersion 2018-04-01")
|
||||||
}
|
}
|
||||||
|
|
||||||
foundImageID := false
|
foundImageID := false
|
||||||
for i := range doc.resources {
|
resources := (*testSubject.template.Resources)
|
||||||
if doc.resources[i]["type"] == "Microsoft.Compute/virtualMachines" {
|
for i := range resources {
|
||||||
storageProfile := doc.resources[i].properties.storageProfile
|
if (*resources[i].Type) == "Microsoft.Compute/virtualMachines" {
|
||||||
if storageProfile.ImageReference != imageID {
|
storageProfile := resources[i].Properties.StorageProfile
|
||||||
|
if (*storageProfile.ImageReference.ID) != imageID {
|
||||||
t.Fatal("ARM template for Shared Image Gallery must have a valid imageID in its storageProfile")
|
t.Fatal("ARM template for Shared Image Gallery must have a valid imageID in its storageProfile")
|
||||||
}
|
}
|
||||||
foundImageID = true
|
foundImageID = true
|
||||||
|
|
Loading…
Reference in New Issue