Skip to content

Commit d7c1bf9

Browse files
committed
Update tests for image licenses
Signed-off-by: Matt Oswalt <[email protected]>
1 parent 8941c5e commit d7c1bf9

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

google/resource_compute_image_test.go

+43-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,32 @@ func TestAccComputeImage_basic(t *testing.T) {
2222
Steps: []resource.TestStep{
2323
resource.TestStep{
2424
Config: testAccComputeImage_basic("image-test-" + acctest.RandString(10)),
25+
Check: resource.ComposeTestCheckFunc(
26+
testAccCheckComputeImageExists(
27+
"google_compute_image.foobar", &image),
28+
testAccCheckComputeImageDescription(&image, "description-test"),
29+
testAccCheckComputeImageFamily(&image, "family-test"),
30+
testAccCheckComputeImageContainsLabel(&image, "my-label", "my-label-value"),
31+
testAccCheckComputeImageContainsLabel(&image, "empty-label", ""),
32+
testAccCheckComputeImageHasComputedFingerprint(&image, "google_compute_image.foobar"),
33+
),
34+
},
35+
},
36+
})
37+
}
38+
39+
func TestAccComputeImage_withLicense(t *testing.T) {
40+
t.Parallel()
41+
42+
var image compute.Image
43+
44+
resource.Test(t, resource.TestCase{
45+
PreCheck: func() { testAccPreCheck(t) },
46+
Providers: testAccProviders,
47+
CheckDestroy: testAccCheckComputeImageDestroy,
48+
Steps: []resource.TestStep{
49+
resource.TestStep{
50+
Config: testAccComputeImage_license("image-test-" + acctest.RandString(10)),
2551
Check: resource.ComposeTestCheckFunc(
2652
testAccCheckComputeImageExists(
2753
"google_compute_image.foobar", &image),
@@ -241,6 +267,23 @@ func testAccCheckComputeImageHasSourceDisk(image *compute.Image) resource.TestCh
241267

242268
func testAccComputeImage_basic(name string) string {
243269
return fmt.Sprintf(`
270+
resource "google_compute_image" "foobar" {
271+
name = "%s"
272+
description = "description-test"
273+
family = "family-test"
274+
raw_disk {
275+
source = "https://storage.googleapis.com/bosh-cpi-artifacts/bosh-stemcell-3262.4-google-kvm-ubuntu-trusty-go_agent-raw.tar.gz"
276+
}
277+
create_timeout = 5
278+
labels = {
279+
my-label = "my-label-value"
280+
empty-label = ""
281+
}
282+
}`, name)
283+
}
284+
285+
func testAccComputeImage_license(name string) string {
286+
return fmt.Sprintf(`
244287
resource "google_compute_image" "foobar" {
245288
name = "%s"
246289
description = "description-test"
@@ -273,9 +316,6 @@ resource "google_compute_image" "foobar" {
273316
empty-label = "oh-look-theres-a-label-now"
274317
new-field = "only-shows-up-when-updated"
275318
}
276-
licenses = [
277-
"https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx",
278-
]
279319
}`, name)
280320
}
281321

0 commit comments

Comments
 (0)