
* eph: add ephemeral resource Adds a new example ephemeral resource using a required configurable attribute and an example ID. * tools: bump terraform-plugin-docs Bump to the latest stable release, as it includes support for ephemeral resource documentation generation. * docs: add ephemeral resource documentation * provider: register new example ephemeral resource * eph: improve alphabetical ordering of struct fields * eph: use a computed 'value' attribute To help provider developers easily understand the concept of ephemeral resources, we use a 'value' attribute in the schema, which is set to an example token (token-123). * docs: update ephemeral resource docs * provider: create a separate echo provider factory container Since not every acceptance test requires an ephemeral provider server for the CLI to connect to and interact with, this introduces a separate provider factory container that includes the echo provider. * eph: add basic acceptance test for ephemeral resource * docs: rename ephemeral resource configuration file * eph: improve http response diag
35 lines
1.5 KiB
Go
35 lines
1.5 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package provider
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform-plugin-framework/providerserver"
|
|
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
|
|
"github.com/hashicorp/terraform-plugin-testing/echoprovider"
|
|
)
|
|
|
|
// testAccProtoV6ProviderFactories is used to instantiate a provider during acceptance testing.
|
|
// The factory function is called for each Terraform CLI command to create a provider
|
|
// server that the CLI can connect to and interact with.
|
|
var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
|
|
"scaffolding": providerserver.NewProtocol6WithError(New("test")()),
|
|
}
|
|
|
|
// testAccProtoV6ProviderFactoriesWithEcho includes the echo provider alongside the scaffolding provider.
|
|
// It allows for testing assertions on data returned by an ephemeral resource during Open.
|
|
// The echoprovider is used to arrange tests by echoing ephemeral data into the Terraform state.
|
|
// This lets the data be referenced in test assertions with state checks.
|
|
var testAccProtoV6ProviderFactoriesWithEcho = map[string]func() (tfprotov6.ProviderServer, error){
|
|
"scaffolding": providerserver.NewProtocol6WithError(New("test")()),
|
|
"echo": echoprovider.NewProviderServer(),
|
|
}
|
|
|
|
func testAccPreCheck(t *testing.T) {
|
|
// You can add code here to run prior to any test case execution, for example assertions
|
|
// about the appropriate environment variables being set are common to see in a pre-check
|
|
// function.
|
|
}
|