Skip to content

Commit 543afd2

Browse files
committed
Add 'prior null nested objects' test
1 parent 41d34b9 commit 543afd2

File tree

1 file changed

+248
-100
lines changed

1 file changed

+248
-100
lines changed

internal/fwserver/schema_propose_new_plan_test.go

Lines changed: 248 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -3603,106 +3603,254 @@ func TestSchemaProposeNewState(t *testing.T) {
36033603
),
36043604
},
36053605
},
3606-
//TODO
3607-
//"prior null nested objects": {
3608-
// schema: schema.Schema{
3609-
// Attributes: map[string]schema.Attribute{
3610-
// "single_nested_attribute": schema.SingleNestedAttribute{
3611-
// Optional: true,
3612-
// Attributes: map[string]schema.Attribute{
3613-
// "nested_list_nested_attribute": schema.ListNestedAttribute{
3614-
// Optional: true,
3615-
// NestedObject: schema.NestedAttributeObject{
3616-
// Attributes: map[string]schema.Attribute{
3617-
// "optional_nested_attribute": schema.StringAttribute{
3618-
// Optional: true,
3619-
// },
3620-
// },
3621-
// },
3622-
// },
3623-
// },
3624-
// },
3625-
// "map_nested_attribute": schema.MapNestedAttribute{
3626-
// Optional: true,
3627-
// NestedObject: schema.NestedAttributeObject{
3628-
// Attributes: map[string]schema.Attribute{
3629-
// "nested_list_nested_attribute": schema.ListNestedAttribute{
3630-
// Optional: true,
3631-
// NestedObject: schema.NestedAttributeObject{
3632-
// Attributes: map[string]schema.Attribute{
3633-
// "optional_nested_attribute": schema.StringAttribute{
3634-
// Optional: true,
3635-
// },
3636-
// },
3637-
// },
3638-
// },
3639-
// },
3640-
// },
3641-
// },
3642-
// },
3643-
// },
3644-
// //TODO:
3645-
// priorVal: map[string]tftypes.Value{
3646-
// "set_nested_attribute": tftypes.NewValue(
3647-
// tftypes.Set{
3648-
// ElementType: tftypes.Object{
3649-
// AttributeTypes: map[string]tftypes.Type{
3650-
// "required_nested_attribute": tftypes.String,
3651-
// },
3652-
// },
3653-
// },
3654-
// []tftypes.Value{
3655-
// tftypes.NewValue(tftypes.Object{
3656-
// AttributeTypes: map[string]tftypes.Type{
3657-
// "required_nested_attribute": tftypes.String,
3658-
// },
3659-
// }, map[string]tftypes.Value{
3660-
// "required_nested_attribute": tftypes.NewValue(tftypes.String, "old"),
3661-
// }),
3662-
// },
3663-
// ),
3664-
// },
3665-
// configVal: map[string]tftypes.Value{
3666-
// "set_nested_attribute": tftypes.NewValue(
3667-
// tftypes.Set{
3668-
// ElementType: tftypes.Object{
3669-
// AttributeTypes: map[string]tftypes.Type{
3670-
// "required_nested_attribute": tftypes.String,
3671-
// },
3672-
// },
3673-
// },
3674-
// []tftypes.Value{
3675-
// tftypes.NewValue(tftypes.Object{
3676-
// AttributeTypes: map[string]tftypes.Type{
3677-
// "required_nested_attribute": tftypes.String,
3678-
// },
3679-
// }, map[string]tftypes.Value{
3680-
// "required_nested_attribute": tftypes.NewValue(tftypes.String, "new"),
3681-
// }),
3682-
// },
3683-
// ),
3684-
// },
3685-
// expectedVal: map[string]tftypes.Value{
3686-
// "set_nested_attribute": tftypes.NewValue(
3687-
// tftypes.Set{
3688-
// ElementType: tftypes.Object{
3689-
// AttributeTypes: map[string]tftypes.Type{
3690-
// "required_nested_attribute": tftypes.String,
3691-
// },
3692-
// },
3693-
// },
3694-
// []tftypes.Value{
3695-
// tftypes.NewValue(tftypes.Object{
3696-
// AttributeTypes: map[string]tftypes.Type{
3697-
// "required_nested_attribute": tftypes.String,
3698-
// },
3699-
// }, map[string]tftypes.Value{
3700-
// "required_nested_attribute": tftypes.NewValue(tftypes.String, "new"),
3701-
// }),
3702-
// },
3703-
// ),
3704-
// },
3705-
//},
3606+
"prior null nested objects": {
3607+
schema: schema.Schema{
3608+
Attributes: map[string]schema.Attribute{
3609+
"single_nested_attribute": schema.SingleNestedAttribute{
3610+
Optional: true,
3611+
Attributes: map[string]schema.Attribute{
3612+
"nested_list_nested_attribute": schema.ListNestedAttribute{
3613+
Optional: true,
3614+
NestedObject: schema.NestedAttributeObject{
3615+
Attributes: map[string]schema.Attribute{
3616+
"optional_nested_attribute": schema.StringAttribute{
3617+
Optional: true,
3618+
},
3619+
},
3620+
},
3621+
},
3622+
},
3623+
},
3624+
"map_nested_attribute": schema.MapNestedAttribute{
3625+
Optional: true,
3626+
NestedObject: schema.NestedAttributeObject{
3627+
Attributes: map[string]schema.Attribute{
3628+
"nested_list_nested_attribute": schema.ListNestedAttribute{
3629+
Optional: true,
3630+
NestedObject: schema.NestedAttributeObject{
3631+
Attributes: map[string]schema.Attribute{
3632+
"optional_nested_attribute": schema.StringAttribute{
3633+
Optional: true,
3634+
},
3635+
},
3636+
},
3637+
},
3638+
},
3639+
},
3640+
},
3641+
},
3642+
},
3643+
priorVal: map[string]tftypes.Value{
3644+
"single_nested_attribute": tftypes.NewValue(
3645+
tftypes.Object{
3646+
AttributeTypes: map[string]tftypes.Type{
3647+
"nested_list_nested_attribute": tftypes.List{ElementType: tftypes.Object{
3648+
AttributeTypes: map[string]tftypes.Type{
3649+
"optional_nested_attribute": tftypes.String,
3650+
},
3651+
}},
3652+
},
3653+
},
3654+
nil,
3655+
),
3656+
"map_nested_attribute": tftypes.NewValue(
3657+
tftypes.Map{
3658+
ElementType: tftypes.Object{
3659+
AttributeTypes: map[string]tftypes.Type{
3660+
"nested_list_nested_attribute": tftypes.List{ElementType: tftypes.Object{
3661+
AttributeTypes: map[string]tftypes.Type{
3662+
"optional_nested_attribute": tftypes.String,
3663+
},
3664+
}},
3665+
},
3666+
},
3667+
},
3668+
map[string]tftypes.Value{
3669+
"one": tftypes.NewValue(tftypes.Object{
3670+
AttributeTypes: map[string]tftypes.Type{
3671+
"nested_list_nested_attribute": tftypes.List{
3672+
ElementType: tftypes.Object{
3673+
AttributeTypes: map[string]tftypes.Type{
3674+
"optional_nested_attribute": tftypes.String,
3675+
},
3676+
},
3677+
},
3678+
}},
3679+
map[string]tftypes.Value{
3680+
"nested_list_nested_attribute": tftypes.NewValue(tftypes.List{
3681+
ElementType: tftypes.Object{
3682+
AttributeTypes: map[string]tftypes.Type{
3683+
"optional_nested_attribute": tftypes.String,
3684+
},
3685+
}},
3686+
[]tftypes.Value{}),
3687+
}),
3688+
},
3689+
),
3690+
},
3691+
configVal: map[string]tftypes.Value{
3692+
"single_nested_attribute": tftypes.NewValue(
3693+
tftypes.Object{
3694+
AttributeTypes: map[string]tftypes.Type{
3695+
"nested_list_nested_attribute": tftypes.List{ElementType: tftypes.Object{
3696+
AttributeTypes: map[string]tftypes.Type{
3697+
"optional_nested_attribute": tftypes.String,
3698+
},
3699+
}},
3700+
},
3701+
},
3702+
map[string]tftypes.Value{
3703+
"nested_list_nested_attribute": tftypes.NewValue(tftypes.List{ElementType: tftypes.Object{
3704+
AttributeTypes: map[string]tftypes.Type{
3705+
"optional_nested_attribute": tftypes.String,
3706+
},
3707+
}},
3708+
[]tftypes.Value{
3709+
tftypes.NewValue(tftypes.Object{
3710+
AttributeTypes: map[string]tftypes.Type{
3711+
"optional_nested_attribute": tftypes.String,
3712+
}}, map[string]tftypes.Value{
3713+
"optional_nested_attribute": tftypes.NewValue(tftypes.String, "a"),
3714+
}),
3715+
tftypes.NewValue(tftypes.Object{
3716+
AttributeTypes: map[string]tftypes.Type{
3717+
"optional_nested_attribute": tftypes.String,
3718+
}}, map[string]tftypes.Value{
3719+
"optional_nested_attribute": tftypes.NewValue(tftypes.String, "b"),
3720+
}),
3721+
}),
3722+
},
3723+
),
3724+
"map_nested_attribute": tftypes.NewValue(
3725+
tftypes.Map{
3726+
ElementType: tftypes.Object{
3727+
AttributeTypes: map[string]tftypes.Type{
3728+
"nested_list_nested_attribute": tftypes.List{ElementType: tftypes.Object{
3729+
AttributeTypes: map[string]tftypes.Type{
3730+
"optional_nested_attribute": tftypes.String,
3731+
},
3732+
}},
3733+
},
3734+
},
3735+
},
3736+
map[string]tftypes.Value{
3737+
"one": tftypes.NewValue(tftypes.Object{
3738+
AttributeTypes: map[string]tftypes.Type{
3739+
"nested_list_nested_attribute": tftypes.List{
3740+
ElementType: tftypes.Object{
3741+
AttributeTypes: map[string]tftypes.Type{
3742+
"optional_nested_attribute": tftypes.String,
3743+
},
3744+
},
3745+
},
3746+
}},
3747+
map[string]tftypes.Value{
3748+
"nested_list_nested_attribute": tftypes.NewValue(tftypes.List{
3749+
ElementType: tftypes.Object{
3750+
AttributeTypes: map[string]tftypes.Type{
3751+
"optional_nested_attribute": tftypes.String,
3752+
},
3753+
}},
3754+
[]tftypes.Value{
3755+
tftypes.NewValue(tftypes.Object{
3756+
AttributeTypes: map[string]tftypes.Type{
3757+
"optional_nested_attribute": tftypes.String,
3758+
}}, map[string]tftypes.Value{
3759+
"optional_nested_attribute": tftypes.NewValue(tftypes.String, "a"),
3760+
}),
3761+
tftypes.NewValue(tftypes.Object{
3762+
AttributeTypes: map[string]tftypes.Type{
3763+
"optional_nested_attribute": tftypes.String,
3764+
}}, map[string]tftypes.Value{
3765+
"optional_nested_attribute": tftypes.NewValue(tftypes.String, "b"),
3766+
}),
3767+
}),
3768+
}),
3769+
},
3770+
),
3771+
},
3772+
expectedVal: map[string]tftypes.Value{
3773+
"single_nested_attribute": tftypes.NewValue(
3774+
tftypes.Object{
3775+
AttributeTypes: map[string]tftypes.Type{
3776+
"nested_list_nested_attribute": tftypes.List{ElementType: tftypes.Object{
3777+
AttributeTypes: map[string]tftypes.Type{
3778+
"optional_nested_attribute": tftypes.String,
3779+
},
3780+
}},
3781+
},
3782+
},
3783+
map[string]tftypes.Value{
3784+
"nested_list_nested_attribute": tftypes.NewValue(tftypes.List{ElementType: tftypes.Object{
3785+
AttributeTypes: map[string]tftypes.Type{
3786+
"optional_nested_attribute": tftypes.String,
3787+
},
3788+
}},
3789+
[]tftypes.Value{
3790+
tftypes.NewValue(tftypes.Object{
3791+
AttributeTypes: map[string]tftypes.Type{
3792+
"optional_nested_attribute": tftypes.String,
3793+
}}, map[string]tftypes.Value{
3794+
"optional_nested_attribute": tftypes.NewValue(tftypes.String, "a"),
3795+
}),
3796+
tftypes.NewValue(tftypes.Object{
3797+
AttributeTypes: map[string]tftypes.Type{
3798+
"optional_nested_attribute": tftypes.String,
3799+
}}, map[string]tftypes.Value{
3800+
"optional_nested_attribute": tftypes.NewValue(tftypes.String, "b"),
3801+
}),
3802+
}),
3803+
},
3804+
),
3805+
"map_nested_attribute": tftypes.NewValue(
3806+
tftypes.Map{
3807+
ElementType: tftypes.Object{
3808+
AttributeTypes: map[string]tftypes.Type{
3809+
"nested_list_nested_attribute": tftypes.List{ElementType: tftypes.Object{
3810+
AttributeTypes: map[string]tftypes.Type{
3811+
"optional_nested_attribute": tftypes.String,
3812+
},
3813+
}},
3814+
},
3815+
},
3816+
},
3817+
map[string]tftypes.Value{
3818+
"one": tftypes.NewValue(tftypes.Object{
3819+
AttributeTypes: map[string]tftypes.Type{
3820+
"nested_list_nested_attribute": tftypes.List{
3821+
ElementType: tftypes.Object{
3822+
AttributeTypes: map[string]tftypes.Type{
3823+
"optional_nested_attribute": tftypes.String,
3824+
},
3825+
},
3826+
},
3827+
}},
3828+
map[string]tftypes.Value{
3829+
"nested_list_nested_attribute": tftypes.NewValue(tftypes.List{
3830+
ElementType: tftypes.Object{
3831+
AttributeTypes: map[string]tftypes.Type{
3832+
"optional_nested_attribute": tftypes.String,
3833+
},
3834+
}},
3835+
[]tftypes.Value{
3836+
tftypes.NewValue(tftypes.Object{
3837+
AttributeTypes: map[string]tftypes.Type{
3838+
"optional_nested_attribute": tftypes.String,
3839+
}}, map[string]tftypes.Value{
3840+
"optional_nested_attribute": tftypes.NewValue(tftypes.String, "a"),
3841+
}),
3842+
tftypes.NewValue(tftypes.Object{
3843+
AttributeTypes: map[string]tftypes.Type{
3844+
"optional_nested_attribute": tftypes.String,
3845+
}}, map[string]tftypes.Value{
3846+
"optional_nested_attribute": tftypes.NewValue(tftypes.String, "b"),
3847+
}),
3848+
}),
3849+
}),
3850+
},
3851+
),
3852+
},
3853+
},
37063854
}
37073855

37083856
for name, test := range tests {

0 commit comments

Comments
 (0)