1- package querycheck
1+ package querycheck_test
22
33import (
4- "regexp"
5- "testing"
6-
74 "github.com/hashicorp/terraform-plugin-go/tfprotov6"
5+ r "github.com/hashicorp/terraform-plugin-testing/helper/resource"
86 "github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider"
97 "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver"
8+ "github.com/hashicorp/terraform-plugin-testing/querycheck"
109 "github.com/hashicorp/terraform-plugin-testing/tfversion"
10+ "regexp"
11+ "testing"
1112)
1213
1314func TestContainsResourceWithName (t * testing.T ) {
1415 t .Parallel ()
1516
16- UnitTest (t , TestCase {
17+ r . UnitTest (t , r. TestCase {
1718 TerraformVersionChecks : []tfversion.TerraformVersionCheck {
1819 tfversion .SkipBelow (tfversion .Version1_14_0 ),
1920 },
2021 ProtoV6ProviderFactories : map [string ]func () (tfprotov6.ProviderServer , error ){
2122 "examplecloud" : providerserver .NewProviderServer (testprovider.Provider {
2223 ListResources : map [string ]testprovider.ListResource {
24+
2325 // TODO: define a simpler resource and list resource here or copy the `examplecloud_test.go` and `examplecloud_list_resource.go` files here for use
24- "examplecloud_containerette" : examplecloudListResource (),
26+
27+ //"examplecloud_containerette": examplecloudListResource(),
2528 },
2629 Resources : map [string ]testprovider.Resource {
27- "examplecloud_containerette" : examplecloudResource (),
30+ // "examplecloud_containerette": examplecloudResource(),
2831 },
2932 }),
3033 },
31- Steps : []TestStep {
34+ Steps : []r. TestStep {
3235 // We'll skip the first test step where we simulate creating the resource that will be returned when we query for it for simplicity.
3336 {
3437 Query : true ,
@@ -51,13 +54,13 @@ func TestContainsResourceWithName(t *testing.T) {
5154 }
5255 }
5356 ` ,
54- QueryResultChecks : []QueryResultCheck {
55- ContainsResourceWithName ("examplecloud_containerette.test" , "banane" ),
56- ContainsResourceWithName ("examplecloud_containerette.test" , "ananas" ),
57- ContainsResourceWithName ("examplecloud_containerette.test" , "kiwi" ),
58- ContainsResourceWithName ("examplecloud_containerette.test2" , "papaya" ),
59- ContainsResourceWithName ("examplecloud_containerette.test2" , "birne" ),
60- ContainsResourceWithName ("examplecloud_containerette.test2" , "kirsche" ),
57+ QueryResultChecks : []querycheck. QueryResultCheck {
58+ querycheck . ContainsResourceWithName ("examplecloud_containerette.test" , "banane" ),
59+ querycheck . ContainsResourceWithName ("examplecloud_containerette.test" , "ananas" ),
60+ querycheck . ContainsResourceWithName ("examplecloud_containerette.test" , "kiwi" ),
61+ querycheck . ContainsResourceWithName ("examplecloud_containerette.test2" , "papaya" ),
62+ querycheck . ContainsResourceWithName ("examplecloud_containerette.test2" , "birne" ),
63+ querycheck . ContainsResourceWithName ("examplecloud_containerette.test2" , "kirsche" ),
6164 },
6265 },
6366 },
@@ -68,22 +71,24 @@ func TestContainsResourceWithName(t *testing.T) {
6871func TestContainsResourceWithName_NotFound (t * testing.T ) {
6972 t .Parallel ()
7073
71- UnitTest (t , TestCase {
74+ r . UnitTest (t , r. TestCase {
7275 TerraformVersionChecks : []tfversion.TerraformVersionCheck {
7376 tfversion .SkipBelow (tfversion .Version1_14_0 ),
7477 },
7578 ProtoV6ProviderFactories : map [string ]func () (tfprotov6.ProviderServer , error ){
7679 "examplecloud" : providerserver .NewProviderServer (testprovider.Provider {
7780 ListResources : map [string ]testprovider.ListResource {
78- // TODO: define a simpler resource and list resource here or copy the `examplecloud_test.go` and `examplecloud_list_resource.go` files here for use
79- "examplecloud_containerette" : examplecloudListResource (),
81+
82+ // TODO: define a resource and list resource here or copy the `examplecloud_test.go` and `examplecloud_list_resource.go` files here for use
83+
84+ //"examplecloud_containerette": examplecloudListResource(),
8085 },
8186 Resources : map [string ]testprovider.Resource {
82- "examplecloud_containerette" : examplecloudResource (),
87+ // "examplecloud_containerette": examplecloudResource(),
8388 },
8489 }),
8590 },
86- Steps : []TestStep {
91+ Steps : []r. TestStep {
8792 {
8893 Query : true ,
8994 Config : `
@@ -105,8 +110,8 @@ func TestContainsResourceWithName_NotFound(t *testing.T) {
105110 }
106111 }
107112 ` ,
108- QueryResultChecks : []QueryResultCheck {
109- ContainsResourceWithName ("examplecloud_containerette.test" , "pflaume" ),
113+ QueryResultChecks : []querycheck. QueryResultCheck {
114+ querycheck . ContainsResourceWithName ("examplecloud_containerette.test" , "pflaume" ),
110115 },
111116 // TODO update expected error message to match what we output
112117 ExpectError : regexp .MustCompile ("examplecloud_containerette.test - there are no pflaumen here!" ),
0 commit comments