fix ResourceInstanceObject.DeepCopy
missing CreateBeforeDestroy
This commit is contained in:
parent
6f35c2847b
commit
bac4e0a3de
|
@ -204,10 +204,11 @@ func (o *ResourceInstanceObject) DeepCopy() *ResourceInstanceObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ResourceInstanceObject{
|
return &ResourceInstanceObject{
|
||||||
Value: o.Value,
|
Value: o.Value,
|
||||||
Status: o.Status,
|
Status: o.Status,
|
||||||
Private: private,
|
Private: private,
|
||||||
Dependencies: dependencies,
|
Dependencies: dependencies,
|
||||||
|
CreateBeforeDestroy: o.CreateBeforeDestroy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package states
|
package states
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-test/deep"
|
"github.com/go-test/deep"
|
||||||
|
@ -191,6 +192,32 @@ func TestState(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStateDeepCopyObject(t *testing.T) {
|
||||||
|
obj := &ResourceInstanceObject{
|
||||||
|
Value: cty.ObjectVal(map[string]cty.Value{
|
||||||
|
"id": cty.StringVal("id"),
|
||||||
|
}),
|
||||||
|
Private: []byte("private"),
|
||||||
|
Status: ObjectReady,
|
||||||
|
Dependencies: []addrs.ConfigResource{
|
||||||
|
{
|
||||||
|
Module: addrs.RootModule,
|
||||||
|
Resource: addrs.Resource{
|
||||||
|
Mode: addrs.ManagedResourceMode,
|
||||||
|
Type: "test_instance",
|
||||||
|
Name: "bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
CreateBeforeDestroy: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
objCopy := obj.DeepCopy()
|
||||||
|
if !reflect.DeepEqual(obj, objCopy) {
|
||||||
|
t.Fatalf("not equal\n%#v\n%#v", obj, objCopy)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestStateDeepCopy(t *testing.T) {
|
func TestStateDeepCopy(t *testing.T) {
|
||||||
state := NewState()
|
state := NewState()
|
||||||
|
|
||||||
|
@ -209,11 +236,12 @@ func TestStateDeepCopy(t *testing.T) {
|
||||||
Name: "baz",
|
Name: "baz",
|
||||||
}.Instance(addrs.IntKey(0)),
|
}.Instance(addrs.IntKey(0)),
|
||||||
&ResourceInstanceObjectSrc{
|
&ResourceInstanceObjectSrc{
|
||||||
Status: ObjectReady,
|
Status: ObjectReady,
|
||||||
SchemaVersion: 1,
|
SchemaVersion: 1,
|
||||||
AttrsJSON: []byte(`{"woozles":"confuzles"}`),
|
AttrsJSON: []byte(`{"woozles":"confuzles"}`),
|
||||||
Private: []byte("private data"),
|
Private: []byte("private data"),
|
||||||
Dependencies: []addrs.ConfigResource{},
|
Dependencies: []addrs.ConfigResource{},
|
||||||
|
CreateBeforeDestroy: true,
|
||||||
},
|
},
|
||||||
addrs.AbsProviderConfig{
|
addrs.AbsProviderConfig{
|
||||||
Provider: addrs.NewDefaultProvider("test"),
|
Provider: addrs.NewDefaultProvider("test"),
|
||||||
|
|
Loading…
Reference in New Issue