-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose internal Diff cross-test interface
- Loading branch information
1 parent
6af66d0
commit 1668a0c
Showing
1 changed file
with
39 additions
and
0 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
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, | ||
}) | ||
} |