Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Miscellaneous doc fixes in attribute + unit tests #1027

Merged
merged 15 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions datasource/schema/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import (
// Attribute define a value field inside the Schema. Implementations in this
// package include:
// - BoolAttribute
// - DynamicAttribute
// - Float32Attribute
// - Float64Attribute
// - Int32Attribute
// - Int64Attribute
// - ListAttribute
// - MapAttribute
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/float64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema"
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-go/tftypes"
Expand Down Expand Up @@ -264,12 +265,12 @@ func TestFloat64AttributeGetType(t *testing.T) {
attribute: schema.Float64Attribute{},
expected: types.Float64Type,
},
// "custom-type": {
// attribute: schema.Float64Attribute{
// CustomType: testtypes.Float64Type{},
// },
// expected: testtypes.Float64Type{},
// },
"custom-type": {
attribute: schema.Float64Attribute{
CustomType: testtypes.Float64Type{},
},
expected: testtypes.Float64Type{},
},
}

for name, testCase := range testCases {
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/int32_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema"
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
)
Expand Down Expand Up @@ -231,12 +232,12 @@ func TestInt32AttributeGetType(t *testing.T) {
attribute: schema.Int32Attribute{},
expected: types.Int32Type,
},
// "custom-type": {
// attribute: schema.Int32Attribute{
// CustomType: testtypes.Int32Type{},
// },
// expected: testtypes.Int32Type{},
// },
"custom-type": {
attribute: schema.Int32Attribute{
CustomType: testtypes.Int32Type{},
},
expected: testtypes.Int32Type{},
},
}

for name, testCase := range testCases {
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/int64_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testschema"
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-go/tftypes"
Expand Down Expand Up @@ -230,12 +231,12 @@ func TestInt64AttributeGetType(t *testing.T) {
attribute: schema.Int64Attribute{},
expected: types.Int64Type,
},
// "custom-type": {
// attribute: schema.Int64Attribute{
// CustomType: testtypes.Int64Type{},
// },
// expected: testtypes.Int64Type{},
// },
"custom-type": {
attribute: schema.Int64Attribute{
CustomType: testtypes.Int64Type{},
},
expected: testtypes.Int64Type{},
},
}

for name, testCase := range testCases {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/list_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ func TestListAttributeGetType(t *testing.T) {
attribute: schema.ListAttribute{ElementType: types.StringType},
expected: types.ListType{ElemType: types.StringType},
},
// "custom-type": {
// attribute: schema.ListAttribute{
// CustomType: testtypes.ListType{},
// },
// expected: testtypes.ListType{},
// },
"custom-type": {
attribute: schema.ListAttribute{
CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
},
expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
},
}

for name, testCase := range testCases {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/list_nested_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ func TestListNestedAttributeGetType(t *testing.T) {
},
},
},
// "custom-type": {
// attribute: schema.ListNestedAttribute{
// CustomType: testtypes.ListType{},
// },
// expected: testtypes.ListType{},
// },
"custom-type": {
attribute: schema.ListNestedAttribute{
CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
},
expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
},
}

for name, testCase := range testCases {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/list_nested_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ func TestListNestedBlockType(t *testing.T) {
},
},
},
// "custom-type": {
// block: schema.ListNestedBlock{
// CustomType: testtypes.ListType{},
// },
// expected: testtypes.ListType{},
// },
"custom-type": {
block: schema.ListNestedBlock{
CustomType: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
},
expected: testtypes.ListType{ListType: types.ListType{ElemType: types.StringType}},
},
}

for name, testCase := range testCases {
Expand Down
4 changes: 2 additions & 2 deletions datasource/schema/map_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
_ fwxschema.AttributeWithMapValidators = MapAttribute{}
)

// MapAttribute represents a schema attribute that is a list with a single
// MapAttribute represents a schema attribute that is a map with a single
// element type. When retrieving the value for this attribute, use types.Map
// as the value type unless the CustomType field is set. The ElementType field
// must be set.
Expand All @@ -32,7 +32,7 @@ var (
// require definition beyond type information.
//
// Terraform configurations configure this attribute using expressions that
// return a list or directly via curly brace syntax.
// return a map or directly via curly brace syntax.
//
// # map of strings
// example_attribute = {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/map_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ func TestMapAttributeGetType(t *testing.T) {
attribute: schema.MapAttribute{ElementType: types.StringType},
expected: types.MapType{ElemType: types.StringType},
},
// "custom-type": {
// attribute: schema.MapAttribute{
// CustomType: testtypes.MapType{},
// },
// expected: testtypes.MapType{},
// },
"custom-type": {
attribute: schema.MapAttribute{
CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}},
},
expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}},
},
}

for name, testCase := range testCases {
Expand Down
6 changes: 3 additions & 3 deletions datasource/schema/map_nested_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
_ fwxschema.AttributeWithMapValidators = MapNestedAttribute{}
)

// MapNestedAttribute represents an attribute that is a set of objects where
// MapNestedAttribute represents an attribute that is a map of objects where
// the object attributes can be fully defined, including further nested
// attributes. When retrieving the value for this attribute, use types.Map
// as the value type unless the CustomType field is set. The NestedObject field
Expand All @@ -35,7 +35,7 @@ var (
// not require definition beyond type information.
//
// Terraform configurations configure this attribute using expressions that
// return a set of objects or directly via curly brace syntax.
// return a map of objects or directly via curly brace syntax.
//
// # map of objects
// example_attribute = {
Expand Down Expand Up @@ -195,7 +195,7 @@ func (a MapNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject {
return a.NestedObject
}

// GetNestingMode always returns NestingModeList.
// GetNestingMode always returns NestingModeMap.
func (a MapNestedAttribute) GetNestingMode() fwschema.NestingMode {
return fwschema.NestingModeMap
}
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/map_nested_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ func TestMapNestedAttributeGetType(t *testing.T) {
},
},
},
// "custom-type": {
// attribute: schema.MapNestedAttribute{
// CustomType: testtypes.MapType{},
// },
// expected: testtypes.MapType{},
// },
"custom-type": {
attribute: schema.MapNestedAttribute{
CustomType: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}},
},
expected: testtypes.MapType{MapType: types.MapType{ElemType: types.StringType}},
},
}

for name, testCase := range testCases {
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/nested_attribute_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-go/tftypes"
Expand Down Expand Up @@ -255,12 +256,12 @@ func TestNestedAttributeObjectType(t *testing.T) {
},
},
},
// "custom-type": {
// block: schema.NestedAttributeObject{
// CustomType: testtypes.SingleType{},
// },
// expected: testtypes.SingleType{},
// },
"custom-type": {
object: schema.NestedAttributeObject{
CustomType: testtypes.ObjectType{},
},
expected: testtypes.ObjectType{},
},
}

for name, testCase := range testCases {
Expand Down
13 changes: 7 additions & 6 deletions datasource/schema/nested_block_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/internal/fwschema"
"github.com/hashicorp/terraform-plugin-framework/internal/testing/testtypes"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-go/tftypes"
Expand Down Expand Up @@ -341,12 +342,12 @@ func TestNestedBlockObjectType(t *testing.T) {
},
},
},
// "custom-type": {
// block: schema.NestedBlockObject{
// CustomType: testtypes.SingleType{},
// },
// expected: testtypes.SingleType{},
// },
"custom-type": {
object: schema.NestedBlockObject{
CustomType: testtypes.ObjectType{},
},
expected: testtypes.ObjectType{},
},
}

for name, testCase := range testCases {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/object_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,12 @@ func TestObjectAttributeGetType(t *testing.T) {
attribute: schema.ObjectAttribute{AttributeTypes: map[string]attr.Type{"testattr": types.StringType}},
expected: types.ObjectType{AttrTypes: map[string]attr.Type{"testattr": types.StringType}},
},
// "custom-type": {
// attribute: schema.ObjectAttribute{
// CustomType: testtypes.ObjectType{},
// },
// expected: testtypes.ObjectType{},
// },
"custom-type": {
attribute: schema.ObjectAttribute{
CustomType: testtypes.ObjectType{},
},
expected: testtypes.ObjectType{},
},
}

for name, testCase := range testCases {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/set_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ func TestSetAttributeGetType(t *testing.T) {
attribute: schema.SetAttribute{ElementType: types.StringType},
expected: types.SetType{ElemType: types.StringType},
},
// "custom-type": {
// attribute: schema.SetAttribute{
// CustomType: testtypes.SetType{},
// },
// expected: testtypes.SetType{},
// },
"custom-type": {
attribute: schema.SetAttribute{
CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
},
expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
},
}

for name, testCase := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion datasource/schema/set_nested_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (a SetNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject {
return a.NestedObject
}

// GetNestingMode always returns NestingModeList.
// GetNestingMode always returns NestingModeSet.
func (a SetNestedAttribute) GetNestingMode() fwschema.NestingMode {
return fwschema.NestingModeSet
}
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/set_nested_attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ func TestSetNestedAttributeGetType(t *testing.T) {
},
},
},
// "custom-type": {
// attribute: schema.SetNestedAttribute{
// CustomType: testtypes.SetType{},
// },
// expected: testtypes.SetType{},
// },
"custom-type": {
attribute: schema.SetNestedAttribute{
CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
},
expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
},
}

for name, testCase := range testCases {
Expand Down
12 changes: 6 additions & 6 deletions datasource/schema/set_nested_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,12 @@ func TestSetNestedBlockType(t *testing.T) {
},
},
},
// "custom-type": {
// block: schema.SetNestedBlock{
// CustomType: testtypes.SetType{},
// },
// expected: testtypes.SetType{},
// },
"custom-type": {
block: schema.SetNestedBlock{
CustomType: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
},
expected: testtypes.SetType{SetType: types.SetType{ElemType: types.StringType}},
},
}

for name, testCase := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion datasource/schema/single_nested_attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (a SingleNestedAttribute) GetNestedObject() fwschema.NestedAttributeObject
}
}

// GetNestingMode always returns NestingModeList.
// GetNestingMode always returns NestingModeSingle.
func (a SingleNestedAttribute) GetNestingMode() fwschema.NestingMode {
return fwschema.NestingModeSingle
}
Expand Down
Loading
Loading