@@ -73,6 +73,15 @@ func TestUnmarshalNestedAllTypes(t *testing.T) {
7373 AttrMANYUpper types.Int64 `tfsdk:"attr_many_upper"`
7474 }
7575
76+ modelCustomTypeBasic := modelCustomTypeTest {
77+ AttrString : types .StringValue ("different_string" ),
78+ AttrInt : types .Int64Value (999 ),
79+ AttrFloat : types .Float64Unknown (),
80+ AttrBool : types .BoolUnknown (),
81+ AttrNested : customtypes.NewObjectValueUnknown [modelEmptyTest ](ctx ),
82+ AttrMANYUpper : types .Int64Value (999 ),
83+ }
84+
7685 type modelst struct {
7786 AttrObj types.Object `tfsdk:"attr_obj"`
7887 AttrObjNullNotSent types.Object `tfsdk:"attr_obj_null_not_sent"`
@@ -117,20 +126,12 @@ func TestUnmarshalNestedAllTypes(t *testing.T) {
117126 "attr_float" : types .Float64Unknown (), // can even be null
118127 "attr_bool" : types .BoolUnknown (), // can even be unknown
119128 }),
120- AttrObjNullNotSent : types .ObjectNull (objTypeTest .AttrTypes ),
121- AttrObjNullSent : types .ObjectNull (objTypeTest .AttrTypes ),
122- AttrObjUnknownNotSent : types .ObjectUnknown (objTypeTest .AttrTypes ), // unknown values are changed to null
123- AttrObjUnknownSent : types .ObjectUnknown (objTypeTest .AttrTypes ),
124- AttrObjParent : types .ObjectNull (objTypeParentTest .AttrTypes ),
125- AttrCustomObj : customtypes .NewObjectValue [modelCustomTypeTest ](ctx , modelCustomTypeTest {
126- // these attribute values are irrelevant, they will be overwritten with JSON values
127- AttrString : types .StringValue ("different_string" ),
128- AttrInt : types .Int64Value (999 ),
129- AttrFloat : types .Float64Unknown (), // can even be unknown
130- AttrBool : types .BoolUnknown (), // can even be unknown
131- AttrNested : customtypes.NewObjectValueUnknown [modelEmptyTest ](ctx ),
132- AttrMANYUpper : types .Int64Value (999 ),
133- }),
129+ AttrObjNullNotSent : types .ObjectNull (objTypeTest .AttrTypes ),
130+ AttrObjNullSent : types .ObjectNull (objTypeTest .AttrTypes ),
131+ AttrObjUnknownNotSent : types .ObjectUnknown (objTypeTest .AttrTypes ), // unknown values are changed to null
132+ AttrObjUnknownSent : types .ObjectUnknown (objTypeTest .AttrTypes ),
133+ AttrObjParent : types .ObjectNull (objTypeParentTest .AttrTypes ),
134+ AttrCustomObj : customtypes .NewObjectValue [modelCustomTypeTest ](ctx , modelCustomTypeBasic ),
134135 AttrCustomObjNullNotSent : customtypes.NewObjectValueNull [modelCustomTypeTest ](ctx ),
135136 AttrCustomObjNullSent : customtypes.NewObjectValueNull [modelCustomTypeTest ](ctx ),
136137 AttrCustomObjUnknownNotSent : customtypes.NewObjectValueUnknown [modelCustomTypeTest ](ctx ), // unknown values are changed to null
@@ -140,10 +141,10 @@ func TestUnmarshalNestedAllTypes(t *testing.T) {
140141 AttrCustomListString : customtypes.NewListValueUnknown [types.String ](ctx ),
141142 AttrListObj : types .ListUnknown (objTypeTest ),
142143 AttrCustomNestedList : customtypes .NewNestedListValue [modelCustomTypeTest ](ctx , []modelCustomTypeTest {
144+ modelCustomTypeBasic ,
143145 {
144- // these attribute values are irrelevant, they will be overwritten with JSON values
145- AttrString : types .StringValue ("different_string" ),
146- AttrInt : types .Int64Value (999 ),
146+ AttrString : types .StringValue ("existing not overwritten" ),
147+ AttrInt : types .Int64Unknown (),
147148 AttrFloat : types .Float64Unknown (),
148149 AttrBool : types .BoolUnknown (),
149150 AttrNested : customtypes.NewObjectValueUnknown [modelEmptyTest ](ctx ),
@@ -156,23 +157,13 @@ func TestUnmarshalNestedAllTypes(t *testing.T) {
156157 AttrCustomNestedListUnknownSent : customtypes.NewNestedListValueUnknown [modelCustomTypeTest ](ctx ),
157158 AttrSetString : types .SetUnknown (types .StringType ),
158159 AttrSetObj : types .SetUnknown (objTypeTest ),
159- AttrCustomNestedSet : customtypes .NewNestedSetValue [modelCustomTypeTest ](ctx , []modelCustomTypeTest {
160- {
161- // these attribute values are irrelevant, they will be overwritten with JSON values
162- AttrString : types .StringValue ("different_string" ),
163- AttrInt : types .Int64Value (999 ),
164- AttrFloat : types .Float64Unknown (),
165- AttrBool : types .BoolUnknown (),
166- AttrNested : customtypes.NewObjectValueUnknown [modelEmptyTest ](ctx ),
167- AttrMANYUpper : types .Int64Value (999 ),
168- },
169- }),
170- AttrCustomNestedSetNullNotSent : customtypes.NewNestedSetValueNull [modelCustomTypeTest ](ctx ),
171- AttrCustomNestedSetNullSent : customtypes.NewNestedSetValueNull [modelCustomTypeTest ](ctx ),
172- AttrCustomNestedSetUnknownNotSent : customtypes.NewNestedSetValueUnknown [modelCustomTypeTest ](ctx ),
173- AttrCustomNestedSetUnknownSent : customtypes.NewNestedSetValueUnknown [modelCustomTypeTest ](ctx ),
174- AttrListListString : types .ListUnknown (types.ListType {ElemType : types .StringType }),
175- AttrSetListObj : types .SetUnknown (types.ListType {ElemType : objTypeTest }),
160+ AttrCustomNestedSet : customtypes .NewNestedSetValue [modelCustomTypeTest ](ctx , []modelCustomTypeTest {modelCustomTypeBasic }),
161+ AttrCustomNestedSetNullNotSent : customtypes.NewNestedSetValueNull [modelCustomTypeTest ](ctx ),
162+ AttrCustomNestedSetNullSent : customtypes.NewNestedSetValueNull [modelCustomTypeTest ](ctx ),
163+ AttrCustomNestedSetUnknownNotSent : customtypes.NewNestedSetValueUnknown [modelCustomTypeTest ](ctx ),
164+ AttrCustomNestedSetUnknownSent : customtypes.NewNestedSetValueUnknown [modelCustomTypeTest ](ctx ),
165+ AttrListListString : types .ListUnknown (types.ListType {ElemType : types .StringType }),
166+ AttrSetListObj : types .SetUnknown (types.ListType {ElemType : objTypeTest }),
176167 AttrListObjKnown : types .ListValueMust (objTypeTest , []attr.Value {
177168 types .ObjectValueMust (objTypeTest .AttrTypes , map [string ]attr.Value {
178169 "attr_string" : types .StringValue ("val" ),
@@ -266,8 +257,6 @@ func TestUnmarshalNestedAllTypes(t *testing.T) {
266257 "attrMANYUpper": 123
267258 },
268259 {
269- "attrString": "nestedList2",
270- "attrInt": 2,
271260 "attrFloat": 2.2,
272261 "attrBool": false,
273262 "attrNested": {},
@@ -490,8 +479,8 @@ func TestUnmarshalNestedAllTypes(t *testing.T) {
490479 AttrMANYUpper : types .Int64Value (123 ),
491480 },
492481 {
493- AttrString : types .StringValue ("nestedList2 " ),
494- AttrInt : types .Int64Value ( 2 ),
482+ AttrString : types .StringValue ("existing not overwritten " ),
483+ AttrInt : types .Int64Unknown ( ),
495484 AttrFloat : types .Float64Value (2.2 ),
496485 AttrBool : types .BoolValue (false ),
497486 AttrNested : customtypes .NewObjectValue [modelEmptyTest ](ctx , modelEmptyTest {}),
0 commit comments