helper/resource: guard id-only by acc var
This commit is contained in:
parent
cb32cb8947
commit
baac14aaeb
|
@ -238,6 +238,12 @@ func UnitTest(t TestT, c TestCase) {
|
|||
}
|
||||
|
||||
func testIDOnlyRefresh(opts terraform.ContextOpts, r *terraform.ResourceState) error {
|
||||
// TODO: We guard by this right now so master doesn't explode. We
|
||||
// need to remove this eventually to make this part of the normal tests.
|
||||
if os.Getenv("TF_ACC_IDONLY") == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
name := fmt.Sprintf("%s.foo", r.Type)
|
||||
|
||||
// Build the state. The state is just the resource with an ID. There
|
||||
|
@ -284,12 +290,20 @@ func testIDOnlyRefresh(opts terraform.ContextOpts, r *terraform.ResourceState) e
|
|||
actual := state.RootModule().Resources[name].Primary.Attributes
|
||||
expected := r.Primary.Attributes
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
// TODO: determine attribute difference
|
||||
// Determine only the different attributes
|
||||
for k, v := range expected {
|
||||
if av, ok := actual[k]; ok && v == av {
|
||||
delete(expected, k)
|
||||
delete(actual, k)
|
||||
}
|
||||
}
|
||||
|
||||
spewConf := spew.NewDefaultConfig()
|
||||
spewConf.SortKeys = true
|
||||
return fmt.Errorf(
|
||||
"Attributes not equivalent. Top is what we received, bottom is expected."+
|
||||
"Attributes not equivalent. Difference is shown below. Top is actual, bottom is expected."+
|
||||
"\n\n%s\n\n%s",
|
||||
spew.Sdump(actual), spew.Sdump(expected))
|
||||
spewConf.Sdump(actual), spewConf.Sdump(expected))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue