-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66f4394
commit 57c6e27
Showing
2 changed files
with
62 additions
and
77 deletions.
There are no files selected for viewing
47 changes: 20 additions & 27 deletions
47
internal/framework/service/example/example_data_source_test.go
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 |
---|---|---|
@@ -1,30 +1,23 @@ | ||
package example | ||
|
||
import ( | ||
"testing" | ||
// func TestAccExampleDataSource(t *testing.T) { | ||
// resource.Test(t, resource.TestCase{ | ||
// PreCheck: func() { provider.TestAccPreCheck(t) }, | ||
// ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, | ||
// Steps: []resource.TestStep{ | ||
// // Read testing | ||
// { | ||
// Config: testAccExampleDataSourceConfig, | ||
// Check: resource.ComposeAggregateTestCheckFunc( | ||
// resource.TestCheckResourceAttr("data.scaffolding_example.test", "id", "example-id"), | ||
// ), | ||
// }, | ||
// }, | ||
// }) | ||
// } | ||
|
||
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/provider" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccExampleDataSource(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { provider.TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
// Read testing | ||
{ | ||
Config: testAccExampleDataSourceConfig, | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.scaffolding_example.test", "id", "example-id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
const testAccExampleDataSourceConfig = ` | ||
data "scaffolding_example" "test" { | ||
configurable_attribute = "example" | ||
} | ||
` | ||
// const testAccExampleDataSourceConfig = ` | ||
// data "scaffolding_example" "test" { | ||
// configurable_attribute = "example" | ||
// } | ||
// ` |
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 |
---|---|---|
@@ -1,53 +1,45 @@ | ||
package example | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
// func TestAccExampleResource(t *testing.T) { | ||
// resource.Test(t, resource.TestCase{ | ||
// PreCheck: func() { provider.TestAccPreCheck(t) }, | ||
// ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, | ||
// Steps: []resource.TestStep{ | ||
// // Create and Read testing | ||
// { | ||
// Config: testAccExampleResourceConfig("one"), | ||
// Check: resource.ComposeAggregateTestCheckFunc( | ||
// resource.TestCheckResourceAttr("scaffolding_example.test", "configurable_attribute", "one"), | ||
// resource.TestCheckResourceAttr("scaffolding_example.test", "id", "example-id"), | ||
// ), | ||
// }, | ||
// // ImportState testing | ||
// { | ||
// ResourceName: "scaffolding_example.test", | ||
// ImportState: true, | ||
// ImportStateVerify: true, | ||
// // This is not normally necessary, but is here because this | ||
// // example code does not have an actual upstream service. | ||
// // Once the Read method is able to refresh information from | ||
// // the upstream service, this can be removed. | ||
// ImportStateVerifyIgnore: []string{"configurable_attribute"}, | ||
// }, | ||
// // Update and Read testing | ||
// { | ||
// Config: testAccExampleResourceConfig("two"), | ||
// Check: resource.ComposeAggregateTestCheckFunc( | ||
// resource.TestCheckResourceAttr("scaffolding_example.test", "configurable_attribute", "two"), | ||
// ), | ||
// }, | ||
// // Delete testing automatically occurs in TestCase | ||
// }, | ||
// }) | ||
// } | ||
|
||
"github.com/cloudflare/terraform-provider-cloudflare/internal/framework/provider" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccExampleResource(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { provider.TestAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: provider.TestAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
// Create and Read testing | ||
{ | ||
Config: testAccExampleResourceConfig("one"), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("scaffolding_example.test", "configurable_attribute", "one"), | ||
resource.TestCheckResourceAttr("scaffolding_example.test", "id", "example-id"), | ||
), | ||
}, | ||
// ImportState testing | ||
{ | ||
ResourceName: "scaffolding_example.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
// This is not normally necessary, but is here because this | ||
// example code does not have an actual upstream service. | ||
// Once the Read method is able to refresh information from | ||
// the upstream service, this can be removed. | ||
ImportStateVerifyIgnore: []string{"configurable_attribute"}, | ||
}, | ||
// Update and Read testing | ||
{ | ||
Config: testAccExampleResourceConfig("two"), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("scaffolding_example.test", "configurable_attribute", "two"), | ||
), | ||
}, | ||
// Delete testing automatically occurs in TestCase | ||
}, | ||
}) | ||
} | ||
|
||
func testAccExampleResourceConfig(configurableAttribute string) string { | ||
return fmt.Sprintf(` | ||
resource "scaffolding_example" "test" { | ||
configurable_attribute = %[1]q | ||
} | ||
`, configurableAttribute) | ||
} | ||
// func testAccExampleResourceConfig(configurableAttribute string) string { | ||
// return fmt.Sprintf(` | ||
// resource "scaffolding_example" "test" { | ||
// configurable_attribute = %[1]q | ||
// } | ||
// `, configurableAttribute) | ||
// } |