Merge pull request #11218 from hashicorp/f-improve-test-function
Differentiate between lookup failure and value inequality.
This commit is contained in:
commit
b4eda2f96c
|
@ -581,7 +581,11 @@ func TestCheckResourceAttr(name, key, value string) TestCheckFunc {
|
|||
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(
|
||||
"%s: Attribute '%s' expected %#v, got %#v",
|
||||
name,
|
||||
|
|
Loading…
Reference in New Issue