-
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.
pulumiTest Integration tests (#2052)
This refactors the cross-tests to expose an integration test module `pulCheck` for use outside of cross-tests. It allows us to easily write integration tests where we specify a TF schema, which gets bridged and use the pulumiTest framework for the test itself. --------- Co-authored-by: Ian Wahbe <ian@wahbe.com>
- Loading branch information
1 parent
d119ed7
commit f5a6151
Showing
13 changed files
with
307 additions
and
275 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,30 @@ | ||
package crosstests | ||
|
||
import ( | ||
"github.com/hashicorp/go-cty/cty" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func FailNotEqual(t T, name string, tfVal, pulVal any) { | ||
t.Logf(name + " not equal!") | ||
t.Logf("TF value %s", tfVal) | ||
t.Logf("PU value %s", pulVal) | ||
t.Fail() | ||
} | ||
|
||
func assertCtyValEqual(t T, name string, tfVal, pulVal cty.Value) { | ||
if !tfVal.RawEquals(pulVal) { | ||
FailNotEqual(t, name, tfVal.GoString(), pulVal.GoString()) | ||
} | ||
} | ||
|
||
func assertValEqual(t T, name string, tfVal, pulVal any) { | ||
// usually plugin-sdk schema types | ||
if hasEqualTfVal, ok := tfVal.(interface{ Equal(interface{}) bool }); ok { | ||
if !hasEqualTfVal.Equal(pulVal) { | ||
FailNotEqual(t, name, tfVal, pulVal) | ||
} | ||
} else { | ||
require.Equal(t, tfVal, pulVal, "Values for key %s do not match", name) | ||
} | ||
} |
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
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,9 @@ | ||
package crosstests | ||
|
||
const ( | ||
defProviderShortName = "crossprovider" | ||
defRtype = "crossprovider_test_res" | ||
defRtok = "TestRes" | ||
defRtoken = defProviderShortName + ":index:" + defRtok | ||
defProviderVer = "0.0.1" | ||
) |
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
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
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
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
Oops, something went wrong.