helper/resource: guard id-only by acc var

This commit is contained in:
Mitchell Hashimoto 2016-04-20 09:34:54 -07:00
parent cb32cb8947
commit baac14aaeb
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 17 additions and 3 deletions

View File

@ -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