crosstests

package
v3.93.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

README

Cross-tests for PF

This package provides cross-testing for Plugin Framework based Terraform providers, bridged into Pulumi with pf.

It does not contain cross-tests. It just provides a library for writing cross-tests.

An example usage looks like this:

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

    schema := schema.Schema{Attributes: map[string]schema.Attribute{
		"k": schema.StringAttribute{Optional: true},
	}}

    tfInput := map[string]cty.Value{"k": cty.StringVal("foo")}

    puInput := resource.PropertyMap{"k": resource.MakeSecret(resource.NewProperty("foo"))}

	crosstests.Configure(schema, tfInput, puInput)
}

Here, the cross-test will assert that a provider whose configuration is described by schema will observe the same inputs when configured in via HCL with the inputs tfInputs and when bridged and configured with Pulumi and puInputs.

The idea is that the "Configured Provider" should not be able to tell if it was configured via HCL or Pulumi YAML:

    +--------------------+                      +---------------------+
    | Terraform Provider |--------------------->| Configure(tfInputs) |
    +--------------------+                      +---------------------+
              |                                                        \
              |                                                         \
              |                                                          \
              |                                                      +---------------------+
              | tfbridge.ShimProvider                                | Configured Provider |
              |                                                      +---------------------+
              |                                                          /
              |                                                         /
              V                                                        /
    +--------------------+                      +---------------------+
    |   Pulumi Provider  |--------------------->| Configure(puInputs) |
    +--------------------+                      +---------------------+

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(t *testing.T, schema schema.Schema, tfConfig map[string]cty.Value, puConfig resource.PropertyMap)

Configure will assert that a provider who's configuration is described by schema will observe the same inputs when configured in via HCL with the inputs tfInputs and when bridged and configured with Pulumi and puInputs.

The idea is that the "Configured Provider" should not be able to tell if it was configured via HCL or Pulumi YAML:

+--------------------+                      +---------------------+
| Terraform Provider |--------------------->| Configure(tfInputs) |
+--------------------+                      +---------------------+
          |                                                        \
          |                                                         \
          |                                                          \
          |                                                      +---------------------+
          | tfbridge.ShimProvider                                | Configured Provider |
          |                                                      +---------------------+
          |                                                          /
          |                                                         /
          V                                                        /
+--------------------+                      +---------------------+
|   Pulumi Provider  |--------------------->| Configure(puInputs) |
+--------------------+                      +---------------------+

Configure should be safe to run in parallel.

func MakeConfigure

func MakeConfigure(schema schema.Schema, tfConfig map[string]cty.Value, puConfig resource.PropertyMap) func(t *testing.T)

MakeConfigure returns a testing subtest of Configure.

func TestMyProperty(t *testing.T) {
	t.Run("my-subtest", crosstests.MakeConfigure(schema, tfConfig, puConfig))
}

For details on the test itself, see Configure.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL