Skip to content

Commit

Permalink
Adding attribute plan modification tests for custom nested types
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Oct 31, 2022
1 parent 225ade9 commit e3f720a
Show file tree
Hide file tree
Showing 2 changed files with 359 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/fwserver/attr_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ func coerceListValue(schemaPath path.Path, value attr.Value) (types.List, diag.D
}

func coerceMapValue(schemaPath path.Path, value attr.Value) (types.Map, diag.Diagnostics) {
m, ok := value.(types.Map)
v := value.ToFrameworkValue()

m, ok := v.(types.Map)
if !ok {
return types.Map{Null: true}, diag.Diagnostics{
attributePlanModificationWalkError(schemaPath, value),
Expand All @@ -38,8 +39,9 @@ func coerceMapValue(schemaPath path.Path, value attr.Value) (types.Map, diag.Dia
}

func coerceObjectValue(schemaPath path.Path, value attr.Value) (types.Object, diag.Diagnostics) {
object, ok := value.(types.Object)
v := value.ToFrameworkValue()

object, ok := v.(types.Object)
if !ok {
return types.Object{Null: true}, diag.Diagnostics{
attributePlanModificationWalkError(schemaPath, value),
Expand All @@ -50,7 +52,9 @@ func coerceObjectValue(schemaPath path.Path, value attr.Value) (types.Object, di
}

func coerceSetValue(schemaPath path.Path, value attr.Value) (types.Set, diag.Diagnostics) {
set, ok := value.(types.Set)
v := value.ToFrameworkValue()

set, ok := v.(types.Set)

if !ok {
return types.Set{Null: true}, diag.Diagnostics{
Expand Down

0 comments on commit e3f720a

Please sign in to comment.