1- package querycheck_test
1+ package querycheck
22
33import (
4+ "regexp"
5+ "testing"
6+
47 "github.com/hashicorp/terraform-plugin-go/tfprotov6"
5- r "github.com/hashicorp/terraform-plugin-testing/helper/resource"
68 "github.com/hashicorp/terraform-plugin-testing/internal/testing/testprovider"
79 "github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver"
8- "github.com/hashicorp/terraform-plugin-testing/querycheck"
910 "github.com/hashicorp/terraform-plugin-testing/tfversion"
10- "regexp"
11- "testing"
1211)
1312
1413func TestContainsResourceWithName (t * testing.T ) {
1514 t .Parallel ()
1615
17- r . UnitTest (t , r. TestCase {
16+ UnitTest (t , TestCase {
1817 TerraformVersionChecks : []tfversion.TerraformVersionCheck {
1918 tfversion .SkipBelow (tfversion .Version1_14_0 ),
2019 },
2120 ProtoV6ProviderFactories : map [string ]func () (tfprotov6.ProviderServer , error ){
2221 "examplecloud" : providerserver .NewProviderServer (testprovider.Provider {
2322 ListResources : map [string ]testprovider.ListResource {
24-
2523 // TODO: define a simpler resource and list resource here or copy the `examplecloud_test.go` and `examplecloud_list_resource.go` files here for use
26-
27- //"examplecloud_containerette": examplecloudListResource(),
24+ "examplecloud_containerette" : examplecloudListResource (),
2825 },
2926 Resources : map [string ]testprovider.Resource {
30- // "examplecloud_containerette": examplecloudResource(),
27+ "examplecloud_containerette" : examplecloudResource (),
3128 },
3229 }),
3330 },
34- Steps : []r. TestStep {
31+ Steps : []TestStep {
3532 // We'll skip the first test step where we simulate creating the resource that will be returned when we query for it for simplicity.
3633 {
3734 Query : true ,
@@ -54,13 +51,13 @@ func TestContainsResourceWithName(t *testing.T) {
5451 }
5552 }
5653 ` ,
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" ),
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" ),
6461 },
6562 },
6663 },
@@ -71,24 +68,22 @@ func TestContainsResourceWithName(t *testing.T) {
7168func TestContainsResourceWithName_NotFound (t * testing.T ) {
7269 t .Parallel ()
7370
74- r . UnitTest (t , r. TestCase {
71+ UnitTest (t , TestCase {
7572 TerraformVersionChecks : []tfversion.TerraformVersionCheck {
7673 tfversion .SkipBelow (tfversion .Version1_14_0 ),
7774 },
7875 ProtoV6ProviderFactories : map [string ]func () (tfprotov6.ProviderServer , error ){
7976 "examplecloud" : providerserver .NewProviderServer (testprovider.Provider {
8077 ListResources : map [string ]testprovider.ListResource {
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(),
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 (),
8580 },
8681 Resources : map [string ]testprovider.Resource {
87- // "examplecloud_containerette": examplecloudResource(),
82+ "examplecloud_containerette" : examplecloudResource (),
8883 },
8984 }),
9085 },
91- Steps : []r. TestStep {
86+ Steps : []TestStep {
9287 {
9388 Query : true ,
9489 Config : `
@@ -110,8 +105,8 @@ func TestContainsResourceWithName_NotFound(t *testing.T) {
110105 }
111106 }
112107 ` ,
113- QueryResultChecks : []querycheck. QueryResultCheck {
114- querycheck . ContainsResourceWithName ("examplecloud_containerette.test" , "pflaume" ),
108+ QueryResultChecks : []QueryResultCheck {
109+ ContainsResourceWithName ("examplecloud_containerette.test" , "pflaume" ),
115110 },
116111 // TODO update expected error message to match what we output
117112 ExpectError : regexp .MustCompile ("examplecloud_containerette.test - there are no pflaumen here!" ),
0 commit comments