-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PF integration tests using pulumitest (#2186)
This adds some utility functions which allow simple integration testing in the PF bridge, similar to the tests in pkg: https://github.com/pulumi/pulumi-terraform-bridge/blob/f317dc4a503d3430fbe13f3af964207f0a17616e/pkg/tests/schema_pulumi_test.go#L19 Builds on `pulumitest`, the `providerbuilder` tools and the `pulcheck` code under `pkg` originally adapted from the cross tests. Allows integration tests to be written against PF, where the schema and the yaml program are specified concisely in the test and pulumitest is used for the actions which allows quite a bit of freedom in expressing pulumi operations.
- Loading branch information
1 parent
59ab72c
commit c57aebd
Showing
2 changed files
with
139 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,42 @@ | ||
package tfbridgetests | ||
|
||
import ( | ||
"testing" | ||
|
||
pschema "github.com/hashicorp/terraform-plugin-framework/provider/schema" | ||
rschema "github.com/hashicorp/terraform-plugin-framework/resource/schema" | ||
"github.com/pulumi/pulumi-terraform-bridge/pf/tests/internal/providerbuilder" | ||
) | ||
|
||
func TestBasic(t *testing.T) { | ||
provBuilder := providerbuilder.Provider{ | ||
TypeName: "prov", | ||
Version: "0.0.1", | ||
ProviderSchema: pschema.Schema{}, | ||
AllResources: []providerbuilder.Resource{ | ||
{ | ||
Name: "test", | ||
ResourceSchema: rschema.Schema{ | ||
Attributes: map[string]rschema.Attribute{ | ||
"s": rschema.StringAttribute{Optional: true}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
prov := bridgedProvider(&provBuilder) | ||
|
||
program := ` | ||
name: test | ||
runtime: yaml | ||
resources: | ||
mainRes: | ||
type: prov:index:Test | ||
properties: | ||
s: "hello"` | ||
|
||
pt := pulCheck(t, prov, program) | ||
|
||
pt.Up() | ||
} |
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