Change description field to not be Computed (#199)

This commit is contained in:
Vincent Roseberry 2017-07-14 15:45:06 -07:00 committed by Dana Hoffman
parent 41202bd464
commit af69c8cead
2 changed files with 34 additions and 1 deletions

View File

@ -31,7 +31,8 @@ func resourceComputeImage() *schema.Resource {
"description": &schema.Schema{
Type: schema.TypeString,
Computed: true,
Optional: true,
ForceNew: true,
},
"family": &schema.Schema{

View File

@ -23,6 +23,8 @@ func TestAccComputeImage_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeImageExists(
"google_compute_image.foobar", &image),
testAccCheckComputeImageDescription(&image, "description-test"),
testAccCheckComputeImageFamily(&image, "family-test"),
),
},
},
@ -42,6 +44,7 @@ func TestAccComputeImage_basedondisk(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeImageExists(
"google_compute_image.foobar", &image),
testAccCheckComputeImageHasSourceDisk(&image),
),
},
},
@ -95,9 +98,38 @@ func testAccCheckComputeImageExists(n string, image *compute.Image) resource.Tes
}
}
func testAccCheckComputeImageDescription(image *compute.Image, description string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if image.Description != description {
return fmt.Errorf("Wrong image description: expected '%s' got '%s'", description, image.Description)
}
return nil
}
}
func testAccCheckComputeImageFamily(image *compute.Image, family string) resource.TestCheckFunc {
return func(s *terraform.State) error {
if image.Family != family {
return fmt.Errorf("Wrong image family: expected '%s' got '%s'", family, image.Family)
}
return nil
}
}
func testAccCheckComputeImageHasSourceDisk(image *compute.Image) resource.TestCheckFunc {
return func(s *terraform.State) error {
if image.SourceType == "" {
return fmt.Errorf("No source disk")
}
return nil
}
}
var testAccComputeImage_basic = fmt.Sprintf(`
resource "google_compute_image" "foobar" {
name = "image-test-%s"
description = "description-test"
family = "family-test"
raw_disk {
source = "https://storage.googleapis.com/bosh-cpi-artifacts/bosh-stemcell-3262.4-google-kvm-ubuntu-trusty-go_agent-raw.tar.gz"
}