-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove usage of plugin framework types in favor of interface types (#…
…2184) This is mostly a migration/refactor from `github.com/hashicorp/terraform-plugin-framework/types/` to `github.com/hashicorp/terraform-plugin-framework/types/basetypes` library. The main functional change is in type_schema.go's Elem() function. Resolves #2119.
- Loading branch information
1 parent
4c5493a
commit 81c9d61
Showing
8 changed files
with
54 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package schemashim | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/resource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/types/basetypes" | ||
"github.com/stretchr/testify/assert" | ||
|
||
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim" | ||
) | ||
|
||
func TestMapAttribute(t *testing.T) { | ||
mapAttr := schema.MapAttribute{ | ||
Optional: true, | ||
ElementType: basetypes.StringType{}, | ||
} | ||
shimmed := &typeSchema{mapAttr.GetType(), nil} | ||
assertIsMapType(t, shimmed) | ||
s := shimmed.Elem().(*typeSchema) | ||
assert.Equal(t, shim.TypeString, s.Type()) | ||
} | ||
|
||
func assertIsMapType(t *testing.T, shimmed shim.Schema) { | ||
assert.Equal(t, shim.TypeMap, shimmed.Type()) | ||
assert.NotNil(t, shimmed.Elem()) | ||
schema, isTypeSchema := shimmed.Elem().(*typeSchema) | ||
assert.Truef(t, isTypeSchema, "expected shim.Elem() to be of type %T", *schema) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters