terraform-provider-dokploy/internal/provider/example_data_source_test.go
Bruno Schaatsbergen 8934cc1ded
provider: migrate to the new plugin testing API (#266)
Migrating from the legacy plugin testing API to the new plan and state check API, which provides improved testing capabilities.
2025-01-22 11:03:57 -05:00

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"
}
`