Skip to content

Commit

Permalink
Expose internal Diff cross-test interface
Browse files Browse the repository at this point in the history
  • Loading branch information
VenelinMartinov committed Dec 11, 2024
1 parent 6af66d0 commit 1668a0c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions pkg/internal/tests/cross-tests/diff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package crosstests

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/zclconf/go-cty/cty"

crosstestsimpl "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/internal/tests/cross-tests/impl"
)

type diffOpts struct {
deleteBeforeReplace bool
}

// An option that can be used to customize [Create].
type DiffOption func(*diffOpts)

// DiffDeleteBeforeReplace specifies a timeout option for [Create].
func DiffDeleteBeforeReplace(deleteBeforeReplace bool) DiffOption {
return func(o *diffOpts) { o.deleteBeforeReplace = deleteBeforeReplace }
}

func Diff(
t T, resource *schema.Resource, config1, config2 map[string]cty.Value, opts ...DiffOption,
) crosstestsimpl.DiffResult {
o := &diffOpts{}
for _, opt := range opts {
opt(o)
}

config1Cty := cty.ObjectVal(config1)
config2Cty := cty.ObjectVal(config2)

return runDiffCheck(t, diffTestCase{
Resource: resource,
Config1: config1Cty,
Config2: config2Cty,
DeleteBeforeReplace: o.deleteBeforeReplace,
})
}

0 comments on commit 1668a0c

Please sign in to comment.