github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/icinga2/utilities_test.go (about) 1 package icinga2 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/helper/resource" 7 "github.com/hashicorp/terraform/terraform" 8 ) 9 10 func testAccCheckResourceState(resourceName, key, value string) resource.TestCheckFunc { 11 return func(s *terraform.State) error { 12 rs, ok := s.RootModule().Resources[resourceName] 13 if !ok { 14 return fmt.Errorf("Not found: %s", resourceName) 15 } 16 if rs.Primary.ID == "" { 17 return fmt.Errorf("No ID is set") 18 } 19 20 p := rs.Primary 21 22 if p.Attributes[key] != value { 23 return fmt.Errorf( 24 "%s != %s (actual: %s)", key, value, p.Attributes[key]) 25 } 26 27 return nil 28 } 29 30 }