diff --git a/internal/fwtype/missing_underlying_type_validation_test.go b/internal/fwtype/missing_underlying_type_validation_test.go index e1e426eb..99931d2b 100644 --- a/internal/fwtype/missing_underlying_type_validation_test.go +++ b/internal/fwtype/missing_underlying_type_validation_test.go @@ -24,11 +24,65 @@ func TestContainsMissingUnderlyingType(t *testing.T) { attrTyp: nil, expected: true, }, - // custom type test cases are below all of the base type test cases "bool": { attrTyp: types.BoolType, expected: false, }, + "custom-bool": { + attrTyp: testtypes.BoolType{}, + expected: false, + }, + "custom-dynamic": { + attrTyp: testtypes.DynamicType{}, + expected: false, + }, + "custom-float64": { + attrTyp: testtypes.Float64Type{}, + expected: false, + }, + "custom-int64": { + attrTyp: testtypes.Int64Type{}, + expected: false, + }, + "custom-list-nil": { + attrTyp: testtypes.ListType{}, + // While testtypes.ListType embeds basetypes.ListType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "custom-map-nil": { + attrTyp: testtypes.MapType{}, + // While testtypes.MapType embeds basetypes.MapType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "custom-object-nil": { + attrTyp: testtypes.ObjectType{}, + expected: false, // expected as objects can be empty + }, + "custom-number": { + attrTyp: testtypes.NumberType{}, + expected: false, + }, + "custom-set-nil": { + attrTyp: testtypes.SetType{}, + // While testtypes.SetType embeds basetypes.SetType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "custom-string": { + attrTyp: testtypes.StringType{}, + expected: false, + }, "dynamic": { attrTyp: types.DynamicType, expected: false, @@ -51,6 +105,142 @@ func TestContainsMissingUnderlyingType(t *testing.T) { }, expected: false, }, + "list-custom-bool": { + attrTyp: types.ListType{ + ElemType: testtypes.BoolType{}, + }, + expected: false, + }, + "list-custom-dynamic": { + attrTyp: types.ListType{ + ElemType: testtypes.DynamicType{}, + }, + expected: false, + }, + "list-custom-float64": { + attrTyp: types.ListType{ + ElemType: testtypes.Float64Type{}, + }, + expected: false, + }, + "list-custom-int64": { + attrTyp: types.ListType{ + ElemType: testtypes.Int64Type{}, + }, + expected: false, + }, + "list-custom-list-nil": { + attrTyp: types.ListType{ + ElemType: testtypes.ListType{}, + }, + // While testtypes.ListType embeds basetypes.ListType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "list-custom-list-string": { + attrTyp: types.ListType{ + ElemType: testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "list-custom-map-nil": { + attrTyp: types.ListType{ + ElemType: testtypes.MapType{}, + }, + // While testtypes.MapType embeds basetypes.MapType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "list-custom-map-string": { + attrTyp: types.ListType{ + ElemType: testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "list-custom-number": { + attrTyp: types.ListType{ + ElemType: testtypes.NumberType{}, + }, + expected: false, + }, + "list-custom-object-nil": { + attrTyp: types.ListType{ + ElemType: testtypes.ObjectType{}, + }, + expected: false, // expected as objects can be empty + }, + "list-custom-object-attrtypes": { + attrTyp: types.ListType{ + ElemType: testtypes.ObjectType{ + ObjectType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": types.Float64Type, + }, + }, + }, + }, + expected: false, + }, + "list-custom-object-attrtypes-nil": { + attrTyp: types.ListType{ + ElemType: testtypes.ObjectType{ + ObjectType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": nil, + }, + }, + }, + }, + // While testtypes.ObjectType embeds basetypes.ObjectType and this + // test case specifies a nil AttrTypes value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // AttributeTypes() method which would be used for custom types. + expected: false, + }, + "list-custom-set-nil": { + attrTyp: types.ListType{ + ElemType: testtypes.SetType{}, + }, + // While testtypes.SetType embeds basetypes.SetType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "list-custom-set-string": { + attrTyp: types.ListType{ + ElemType: testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "list-custom-string": { + attrTyp: types.ListType{ + ElemType: testtypes.StringType{}, + }, + expected: false, + }, "list-dynamic": { attrTyp: types.ListType{ ElemType: types.DynamicType, @@ -188,6 +378,142 @@ func TestContainsMissingUnderlyingType(t *testing.T) { }, expected: false, }, + "map-custom-bool": { + attrTyp: types.MapType{ + ElemType: testtypes.BoolType{}, + }, + expected: false, + }, + "map-custom-dynamic": { + attrTyp: types.MapType{ + ElemType: testtypes.DynamicType{}, + }, + expected: false, + }, + "map-custom-float64": { + attrTyp: types.MapType{ + ElemType: testtypes.Float64Type{}, + }, + expected: false, + }, + "map-custom-int64": { + attrTyp: types.MapType{ + ElemType: testtypes.Int64Type{}, + }, + expected: false, + }, + "map-custom-list-nil": { + attrTyp: types.MapType{ + ElemType: testtypes.ListType{}, + }, + // While testtypes.ListType embeds basetypes.ListType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "map-custom-list-string": { + attrTyp: types.MapType{ + ElemType: testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "map-custom-map-nil": { + attrTyp: types.MapType{ + ElemType: testtypes.MapType{}, + }, + // While testtypes.MapType embeds basetypes.MapType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "map-custom-map-string": { + attrTyp: types.MapType{ + ElemType: testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "map-custom-number": { + attrTyp: types.MapType{ + ElemType: testtypes.NumberType{}, + }, + expected: false, + }, + "map-custom-object-nil": { + attrTyp: types.MapType{ + ElemType: testtypes.ObjectType{}, + }, + expected: false, // expected as objects can be empty + }, + "map-custom-object-attrtypes": { + attrTyp: types.MapType{ + ElemType: testtypes.ObjectType{ + ObjectType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": types.Float64Type, + }, + }, + }, + }, + expected: false, + }, + "map-custom-object-attrtypes-nil": { + attrTyp: types.MapType{ + ElemType: testtypes.ObjectType{ + ObjectType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": nil, + }, + }, + }, + }, + // While testtypes.ObjectType embeds basetypes.ObjectType and this + // test case specifies a nil AttrTypes value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // AttributeTypes() method which would be used for custom types. + expected: false, + }, + "map-custom-set-nil": { + attrTyp: types.MapType{ + ElemType: testtypes.SetType{}, + }, + // While testtypes.SetType embeds basetypes.SetType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "map-custom-set-string": { + attrTyp: types.MapType{ + ElemType: testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "map-custom-string": { + attrTyp: types.MapType{ + ElemType: testtypes.StringType{}, + }, + expected: false, + }, "map-dynamic": { attrTyp: types.MapType{ ElemType: types.DynamicType, @@ -251,78 +577,729 @@ func TestContainsMissingUnderlyingType(t *testing.T) { }, expected: false, }, - "map-object-attrtypes-nil": { - attrTyp: types.MapType{ - ElemType: types.ObjectType{ - AttrTypes: map[string]attr.Type{ - "bool": types.BoolType, - "nil": nil, + "map-object-attrtypes-nil": { + attrTyp: types.MapType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "nil": nil, + }, + }, + }, + expected: true, + }, + "map-number": { + attrTyp: types.MapType{ + ElemType: types.NumberType, + }, + expected: false, + }, + "map-set-nil": { + attrTyp: types.MapType{ + ElemType: types.SetType{}, + }, + expected: true, + }, + "map-set-string": { + attrTyp: types.MapType{ + ElemType: types.SetType{ + ElemType: types.StringType, + }, + }, + expected: false, + }, + "map-string": { + attrTyp: types.MapType{ + ElemType: types.StringType, + }, + expected: false, + }, + "map-tuple-nil": { + attrTyp: types.MapType{ + ElemType: types.TupleType{}, + }, + expected: false, // expected as tuples can be empty + }, + "map-tuple-elemtypes": { + attrTyp: types.MapType{ + ElemType: types.TupleType{ + ElemTypes: []attr.Type{ + types.StringType, + }, + }, + }, + expected: false, + }, + "map-tuple-elemtypes-nil": { + attrTyp: types.MapType{ + ElemType: types.TupleType{ + ElemTypes: []attr.Type{ + types.StringType, + nil, + }, + }, + }, + expected: true, + }, + "number": { + attrTyp: types.NumberType, + expected: false, + }, + "object-nil": { + attrTyp: types.ObjectType{}, + expected: false, // expected as objects can be empty + }, + "object-custom-list-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{}, + }, + }, + // While testtypes.ListType embeds basetypes.ListType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "object-custom-list-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.StringType, + }, + }, + }, + }, + expected: false, + }, + "object-custom-list-list-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.ListType{}, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-list-list-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.ListType{ + ElemType: types.StringType, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-list-map-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.MapType{}, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-list-map-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.MapType{ + ElemType: types.StringType, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-list-object-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.ObjectType{}, + }, + }, + }, + }, + expected: false, // expected as objects can be empty + }, + "object-custom-list-object-attrtypes": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": types.Float64Type, + }, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-list-object-attrtypes-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "nil": nil, + }, + }, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-list-set-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.SetType{}, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-list-set-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.SetType{ + ElemType: types.StringType, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-list-tuple-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.TupleType{}, + }, + }, + }, + }, + expected: false, // expected as tuples can be empty + }, + "object-custom-list-tuple-elemtypes": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.TupleType{ + ElemTypes: []attr.Type{ + types.BoolType, + types.Float64Type, + }, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-list-tuple-elemtypes-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "list": testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.TupleType{ + ElemTypes: []attr.Type{ + types.BoolType, + nil, + }, + }, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-map-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{}, + }, + }, + // While testtypes.MapType embeds basetypes.MapType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "object-custom-map-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.StringType, + }, + }, + }, + }, + expected: false, + }, + "object-custom-map-list-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.ListType{}, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-map-list-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.ListType{ + ElemType: types.StringType, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-map-map-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.MapType{}, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-map-map-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.MapType{ + ElemType: types.StringType, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-map-object-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.ObjectType{}, + }, + }, + }, + }, + expected: false, // expected as objects can be empty + }, + "object-custom-map-object-attrtypes": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": types.Float64Type, + }, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-map-object-attrtypes-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "nil": nil, + }, + }, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-map-set-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.SetType{}, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-map-set-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.SetType{ + ElemType: types.StringType, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-map-tuple-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.TupleType{}, + }, + }, + }, + }, + expected: false, // expected as tuples can be empty + }, + "object-custom-map-tuple-elemtypes": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.TupleType{ + ElemTypes: []attr.Type{ + types.BoolType, + types.Float64Type, + }, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-map-tuple-elemtypes-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "map": testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.TupleType{ + ElemTypes: []attr.Type{ + types.BoolType, + nil, + }, + }, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-object-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "object": testtypes.ObjectType{}, + }, + }, + expected: false, // expected as objects can be empty + }, + "object-custom-object-attrtypes": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "object": testtypes.ObjectType{ + ObjectType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": types.Float64Type, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-object-attrtypes-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "object": testtypes.ObjectType{ + ObjectType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "nil": nil, + }, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-set-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{}, + }, + }, + // While testtypes.SetType embeds basetypes.SetType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "object-custom-set-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.StringType, + }, + }, + }, + }, + expected: false, + }, + "object-custom-set-list-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.ListType{}, + }, + }, + }, + }, + expected: false, + }, + "object-custom-set-list-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.ListType{ + ElemType: types.StringType, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-set-map-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.MapType{}, + }, + }, + }, + }, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, + }, + "object-custom-set-map-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.MapType{ + ElemType: types.StringType, + }, + }, + }, + }, + }, + expected: false, + }, + "object-custom-set-object-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.ObjectType{}, + }, }, }, }, - expected: true, + expected: false, // expected as objects can be empty }, - "map-number": { - attrTyp: types.MapType{ - ElemType: types.NumberType, + "object-custom-set-object-attrtypes": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": types.Float64Type, + }, + }, + }, + }, + }, }, expected: false, }, - "map-set-nil": { - attrTyp: types.MapType{ - ElemType: types.SetType{}, + "object-custom-set-object-attrtypes-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "nil": nil, + }, + }, + }, + }, + }, }, - expected: true, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. + expected: false, }, - "map-set-string": { - attrTyp: types.MapType{ - ElemType: types.SetType{ - ElemType: types.StringType, + "object-custom-set-set-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.SetType{}, + }, + }, }, }, expected: false, }, - "map-string": { - attrTyp: types.MapType{ - ElemType: types.StringType, + "object-custom-set-set-string": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.SetType{ + ElemType: types.StringType, + }, + }, + }, + }, }, expected: false, }, - "map-tuple-nil": { - attrTyp: types.MapType{ - ElemType: types.TupleType{}, + "object-custom-set-tuple-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.TupleType{}, + }, + }, + }, }, expected: false, // expected as tuples can be empty }, - "map-tuple-elemtypes": { - attrTyp: types.MapType{ - ElemType: types.TupleType{ - ElemTypes: []attr.Type{ - types.StringType, + "object-custom-set-tuple-elemtypes": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.TupleType{ + ElemTypes: []attr.Type{ + types.BoolType, + types.Float64Type, + }, + }, + }, }, }, }, expected: false, }, - "map-tuple-elemtypes-nil": { - attrTyp: types.MapType{ - ElemType: types.TupleType{ - ElemTypes: []attr.Type{ - types.StringType, - nil, + "object-custom-set-tuple-elemtypes-nil": { + attrTyp: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "set": testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.TupleType{ + ElemTypes: []attr.Type{ + types.BoolType, + nil, + }, + }, + }, }, }, }, - expected: true, - }, - "number": { - attrTyp: types.NumberType, + // Similar to other custom type test cases, the custom type will + // prevent the further checking of the element type. expected: false, }, - "object-nil": { - attrTyp: types.ObjectType{}, - expected: false, // expected as objects can be empty - }, "object-list-nil": { attrTyp: types.ObjectType{ AttrTypes: map[string]attr.Type{ @@ -1037,6 +2014,142 @@ func TestContainsMissingUnderlyingType(t *testing.T) { }, expected: false, }, + "set-custom-bool": { + attrTyp: types.SetType{ + ElemType: testtypes.BoolType{}, + }, + expected: false, + }, + "set-custom-dynamic": { + attrTyp: types.SetType{ + ElemType: testtypes.DynamicType{}, + }, + expected: false, + }, + "set-custom-float64": { + attrTyp: types.SetType{ + ElemType: testtypes.Float64Type{}, + }, + expected: false, + }, + "set-custom-int64": { + attrTyp: types.SetType{ + ElemType: testtypes.Int64Type{}, + }, + expected: false, + }, + "set-custom-list-nil": { + attrTyp: types.SetType{ + ElemType: testtypes.ListType{}, + }, + // While testtypes.ListType embeds basetypes.ListType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "set-custom-list-string": { + attrTyp: types.SetType{ + ElemType: testtypes.ListType{ + ListType: types.ListType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "set-custom-map-nil": { + attrTyp: types.SetType{ + ElemType: testtypes.MapType{}, + }, + // While testtypes.MapType embeds basetypes.MapType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "set-custom-map-string": { + attrTyp: types.SetType{ + ElemType: testtypes.MapType{ + MapType: types.MapType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "set-custom-number": { + attrTyp: types.SetType{ + ElemType: testtypes.NumberType{}, + }, + expected: false, + }, + "set-custom-object-nil": { + attrTyp: types.SetType{ + ElemType: testtypes.ObjectType{}, + }, + expected: false, // expected as objects can be empty + }, + "set-custom-object-attrtypes": { + attrTyp: types.SetType{ + ElemType: testtypes.ObjectType{ + ObjectType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": types.Float64Type, + }, + }, + }, + }, + expected: false, + }, + "set-custom-object-attrtypes-nil": { + attrTyp: types.SetType{ + ElemType: testtypes.ObjectType{ + ObjectType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "bool": types.BoolType, + "float64": nil, + }, + }, + }, + }, + // While testtypes.ObjectType embeds basetypes.ObjectType and this + // test case specifies a nil AttrTypes value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // AttributeTypes() method which would be used for custom types. + expected: false, + }, + "set-custom-set-nil": { + attrTyp: types.SetType{ + ElemType: testtypes.SetType{}, + }, + // While testtypes.SetType embeds basetypes.SetType and this test + // case does not specify an ElemType value, the function logic is + // coded to only handle basetypes implementations due to the + // unexported missingType that would be returned from the + // ElementType() method which would be used for custom types. + expected: false, + }, + "set-custom-set-string": { + attrTyp: types.SetType{ + ElemType: testtypes.SetType{ + SetType: types.SetType{ + ElemType: types.StringType, + }, + }, + }, + expected: false, + }, + "set-custom-string": { + attrTyp: types.SetType{ + ElemType: testtypes.StringType{}, + }, + expected: false, + }, "set-dynamic": { attrTyp: types.SetType{ ElemType: types.DynamicType, @@ -1596,61 +2709,6 @@ func TestContainsMissingUnderlyingType(t *testing.T) { }, expected: true, }, - "custom-bool": { - attrTyp: testtypes.BoolType{}, - expected: false, - }, - "custom-dynamic": { - attrTyp: testtypes.DynamicType{}, - expected: false, - }, - "custom-float64": { - attrTyp: testtypes.Float64Type{}, - expected: false, - }, - "custom-int64": { - attrTyp: testtypes.Int64Type{}, - expected: false, - }, - "custom-list-nil": { - attrTyp: testtypes.ListType{}, - // While testtypes.ListType embeds basetypes.ListType and this test - // case does not specify an ElemType value, the function logic is - // coded to only handle basetypes implementations due to the - // unexported missingType that would be returned from the - // ElementType() method which would be used for custom types. - expected: false, - }, - "custom-map-nil": { - attrTyp: testtypes.MapType{}, - // While testtypes.MapType embeds basetypes.MapType and this test - // case does not specify an ElemType value, the function logic is - // coded to only handle basetypes implementations due to the - // unexported missingType that would be returned from the - // ElementType() method which would be used for custom types. - expected: false, - }, - "custom-object-nil": { - attrTyp: testtypes.ObjectType{}, - expected: false, // expected as objects can be empty - }, - "custom-number": { - attrTyp: testtypes.NumberType{}, - expected: false, - }, - "custom-set-nil": { - attrTyp: testtypes.SetType{}, - // While testtypes.SetType embeds basetypes.SetType and this test - // case does not specify an ElemType value, the function logic is - // coded to only handle basetypes implementations due to the - // unexported missingType that would be returned from the - // ElementType() method which would be used for custom types. - expected: false, - }, - "custom-string": { - attrTyp: testtypes.StringType{}, - expected: false, - }, } for name, testCase := range testCases { name, testCase := name, testCase