@@ -17,12 +17,16 @@ import (
1717 "github.com/hashicorp/go-cty/cty"
1818 "github.com/hashicorp/terraform-plugin-go/tfprotov5"
1919 "github.com/hashicorp/terraform-plugin-go/tfprotov6"
20+ "github.com/hashicorp/terraform-plugin-go/tftypes"
2021
2122 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
2223 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
2324 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
2425
2526 "github.com/hashicorp/terraform-plugin-testing/internal/plugintest"
27+ "github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider"
28+ "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver"
29+ "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource"
2630 "github.com/hashicorp/terraform-plugin-testing/terraform"
2731)
2832
@@ -1142,6 +1146,53 @@ func TestTest_TestStep_ExternalProvidersAndProviderFactories_NonHashiCorpNamespa
11421146 })
11431147}
11441148
1149+ func TestTest_TestStep_ExternalProviders_To_ProtoV6ProviderFactories (t * testing.T ) {
1150+ t .Parallel ()
1151+
1152+ Test (t , TestCase {
1153+ Steps : []TestStep {
1154+ {
1155+ Config : `resource "null_resource" "test" {}` ,
1156+ ExternalProviders : map [string ]ExternalProvider {
1157+ "null" : {
1158+ Source : "registry.terraform.io/hashicorp/null" ,
1159+ VersionConstraint : "3.1.1" ,
1160+ },
1161+ },
1162+ },
1163+ {
1164+ Config : `resource "null_resource" "test" {}` ,
1165+ ProtoV6ProviderFactories : map [string ]func () (tfprotov6.ProviderServer , error ){
1166+ "null" : providerserver .NewProviderServer (testprovider.Provider {
1167+ Resources : map [string ]testprovider.Resource {
1168+ "null_resource" : {
1169+ SchemaResponse : & resource.SchemaResponse {
1170+ Schema : & tfprotov6.Schema {
1171+ Block : & tfprotov6.SchemaBlock {
1172+ Attributes : []* tfprotov6.SchemaAttribute {
1173+ {
1174+ Name : "id" ,
1175+ Type : tftypes .String ,
1176+ Computed : true ,
1177+ },
1178+ {
1179+ Name : "triggers" ,
1180+ Type : tftypes.Map {ElementType : tftypes .String },
1181+ Optional : true ,
1182+ },
1183+ },
1184+ },
1185+ },
1186+ },
1187+ },
1188+ },
1189+ }),
1190+ },
1191+ },
1192+ },
1193+ })
1194+ }
1195+
11451196func TestTest_TestStep_ExternalProviders_To_ProviderFactories (t * testing.T ) {
11461197 t .Parallel ()
11471198
@@ -1406,6 +1457,66 @@ func TestTest_TestStep_ProtoV6ProviderFactories_Error(t *testing.T) {
14061457 })
14071458}
14081459
1460+ func TestTest_TestStep_ProtoV6ProviderFactories_To_ExternalProviders (t * testing.T ) {
1461+ t .Parallel ()
1462+
1463+ Test (t , TestCase {
1464+ Steps : []TestStep {
1465+ {
1466+ Config : `resource "null_resource" "test" {}` ,
1467+ ProtoV6ProviderFactories : map [string ]func () (tfprotov6.ProviderServer , error ){
1468+ "null" : providerserver .NewProviderServer (testprovider.Provider {
1469+ Resources : map [string ]testprovider.Resource {
1470+ "null_resource" : {
1471+ CreateResponse : & resource.CreateResponse {
1472+ NewState : tftypes .NewValue (
1473+ tftypes.Object {
1474+ AttributeTypes : map [string ]tftypes.Type {
1475+ "id" : tftypes .String ,
1476+ "triggers" : tftypes.Map {ElementType : tftypes .String },
1477+ },
1478+ },
1479+ map [string ]tftypes.Value {
1480+ "id" : tftypes .NewValue (tftypes .String , "test" ),
1481+ "triggers" : tftypes .NewValue (tftypes.Map {ElementType : tftypes .String }, nil ),
1482+ },
1483+ ),
1484+ },
1485+ SchemaResponse : & resource.SchemaResponse {
1486+ Schema : & tfprotov6.Schema {
1487+ Block : & tfprotov6.SchemaBlock {
1488+ Attributes : []* tfprotov6.SchemaAttribute {
1489+ {
1490+ Name : "id" ,
1491+ Type : tftypes .String ,
1492+ Computed : true ,
1493+ },
1494+ {
1495+ Name : "triggers" ,
1496+ Type : tftypes.Map {ElementType : tftypes .String },
1497+ Optional : true ,
1498+ },
1499+ },
1500+ },
1501+ },
1502+ },
1503+ },
1504+ },
1505+ }),
1506+ },
1507+ },
1508+ {
1509+ Config : `resource "null_resource" "test" {}` ,
1510+ ExternalProviders : map [string ]ExternalProvider {
1511+ "null" : {
1512+ Source : "registry.terraform.io/hashicorp/null" ,
1513+ },
1514+ },
1515+ },
1516+ },
1517+ })
1518+ }
1519+
14091520func TestTest_TestStep_ProviderFactories (t * testing.T ) {
14101521 t .Parallel ()
14111522
0 commit comments