github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/builtin/providers/dns/test_check_attr_string_array_member.go (about) 1 package dns 2 3 import ( 4 "fmt" 5 6 r "github.com/hashicorp/terraform/helper/resource" 7 "github.com/hashicorp/terraform/terraform" 8 ) 9 10 func testCheckAttrStringArrayMember(name, key string, value []string) r.TestCheckFunc { 11 return func(s *terraform.State) error { 12 ms := s.RootModule() 13 rs, ok := ms.Resources[name] 14 if !ok { 15 return fmt.Errorf("Not found: %s", name) 16 } 17 18 is := rs.Primary 19 if is == nil { 20 return fmt.Errorf("No primary instance: %s", name) 21 } 22 23 got, ok := is.Attributes[key] 24 if !ok { 25 return fmt.Errorf("Attributes not found for %s", key) 26 } 27 28 for _, want := range value { 29 if got == want { 30 return nil 31 } 32 } 33 34 return fmt.Errorf( 35 "Unexpected value for %s: got %s", 36 key, 37 got) 38 } 39 }