terraform: test case for if diff returns nil
This commit is contained in:
parent
743c3684c5
commit
061d96a08b
|
@ -154,7 +154,7 @@ func (t *Terraform) diffWalkFn(
|
|||
}
|
||||
|
||||
// If there were no diff items, return right away
|
||||
if len(diff.Attributes) == 0 {
|
||||
if diff == nil || len(diff.Attributes) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -202,6 +202,18 @@ func TestTerraformDiff(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestTerraformDiff_nil(t *testing.T) {
|
||||
tf := testTerraform(t, "diff-nil")
|
||||
|
||||
diff, err := tf.Diff(nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
if len(diff.Resources) != 0 {
|
||||
t.Fatalf("bad: %#v", diff.Resources)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTerraformDiff_computed(t *testing.T) {
|
||||
tf := testTerraform(t, "diff-computed")
|
||||
|
||||
|
@ -269,6 +281,10 @@ func testProviderFunc(n string, rs []string) ResourceProviderFactory {
|
|||
continue
|
||||
}
|
||||
|
||||
if k == "nil" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if k == "compute" {
|
||||
diff.Attributes[v.(string)] = &ResourceAttrDiff{
|
||||
Old: "",
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
resource "aws_instance" "foo" {
|
||||
nil = "1"
|
||||
}
|
Loading…
Reference in New Issue