
Migrating from the legacy plugin testing API to the new plan and state check API, which provides improved testing capabilities.
40 lines
1002 B
Go
40 lines
1002 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package provider
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
|
|
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
|
|
"github.com/hashicorp/terraform-plugin-testing/statecheck"
|
|
"github.com/hashicorp/terraform-plugin-testing/tfjsonpath"
|
|
)
|
|
|
|
func TestAccExampleDataSource(t *testing.T) {
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
|
|
Steps: []resource.TestStep{
|
|
// Read testing
|
|
{
|
|
Config: testAccExampleDataSourceConfig,
|
|
ConfigStateChecks: []statecheck.StateCheck{
|
|
statecheck.ExpectKnownValue(
|
|
"data.scaffolding_example.test",
|
|
tfjsonpath.New("id"),
|
|
knownvalue.StringExact("example-id"),
|
|
),
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
const testAccExampleDataSourceConfig = `
|
|
data "scaffolding_example" "test" {
|
|
configurable_attribute = "example"
|
|
}
|
|
`
|