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)
|
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,
|
||||||
|
|
Loading…
Reference in New Issue