diff --git a/helper/resource/testing.go b/helper/resource/testing.go index 29a767f81..5505da0ab 100644 --- a/helper/resource/testing.go +++ b/helper/resource/testing.go @@ -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