Merge pull request #11218 from hashicorp/f-improve-test-function

Differentiate between lookup failure and value inequality.
This commit is contained in:
James Nugent 2017-01-15 22:59:41 +00:00 committed by GitHub
commit b4eda2f96c
1 changed files with 5 additions and 1 deletions

View File

@ -581,7 +581,11 @@ func TestCheckResourceAttr(name, key, value string) TestCheckFunc {
return fmt.Errorf("No primary instance: %s", name) return fmt.Errorf("No primary instance: %s", name)
} }
if is.Attributes[key] != value { if v, ok := is.Attributes[key]; !ok || v != value {
if !ok {
return fmt.Errorf("%s: Attribute '%s' not found", name, key)
}
return fmt.Errorf( return fmt.Errorf(
"%s: Attribute '%s' expected %#v, got %#v", "%s: Attribute '%s' expected %#v, got %#v",
name, name,