Skip to content

Commit

Permalink
Test int->string type overrides with cross-tests (#2502)
Browse files Browse the repository at this point in the history
Fixes #2048
  • Loading branch information
iwahbe authored Oct 18, 2024
1 parent 1dd0380 commit 93162c7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/tfbridge/tests/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,47 @@ import (
"encoding/json"
"fmt"
"io"
"math"
"strconv"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/pulumi/providertest/replay"
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
pulumirpc "github.com/pulumi/pulumi/sdk/v3/proto/go"
"github.com/zclconf/go-cty/cty"

"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen"
shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
)

func TestIntToStringOverride(t *testing.T) {
t.Parallel()

const largeInt = math.MaxInt64 / 2

crosstests.Create(t,
map[string]*schema.Schema{
"f0": {Required: true, Type: schema.TypeInt},
},
cty.ObjectVal(map[string]cty.Value{
"f0": cty.NumberIntVal(largeInt),
}),
resource.PropertyMap{
"f0": resource.NewProperty(strconv.FormatInt(largeInt, 10)),
},
crosstests.CreateResourceInfo(info.Resource{Fields: map[string]*info.Schema{
"f0": {Type: "string"},
}}),
)
}

// Demonstrating the use of the newTestProvider helper.
func TestWithNewTestProvider(t *testing.T) {
ctx := context.Background()
Expand Down

0 comments on commit 93162c7

Please sign in to comment.