Documentation ¶
Overview ¶
Copyright (c) HashiCorp, Inc. SPDX-License-Identifier: MPL-2.0
Copyright (c) HashiCorp, Inc. SPDX-License-Identifier: MPL-2.0
Index ¶
- func AddTestSweepers(name string, sweeper func(region string) error)
- func ExecuteSweepers(t *testing.T)
- func IsSweepableTestResource(resourceName string) bool
- func ListParentResourcesInLocation(d *tpgresource.ResourceDataMock, config *transport_tpg.Config, ...) ([]string, error)
- func SharedConfigForRegion(region string) (*transport_tpg.Config, error)
- type Sweeper
- type SweeperFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTestSweepers ¶
func ExecuteSweepers ¶
ExecuteSweepers
Sweepers enable infrastructure cleanup functions to be included with resource definitions, typically so developers can remove all resources of that resource type from testing infrastructure in case of failures that prevented the normal resource destruction behavior of acceptance tests. Use the AddTestSweepers() function to configure available sweepers.
Sweeper flags added to the "go test" command:
-sweep: Comma-separated list of locations/regions to run available sweepers. -sweep-allow-failues: Enable to allow other sweepers to run after failures. -sweep-run: Comma-separated list of resource type sweepers to run. Defaults to all sweepers.
Refer to the Env prefixed constants for environment variables that further control testing functionality.
func IsSweepableTestResource ¶
func ListParentResourcesInLocation ¶
func ListParentResourcesInLocation(d *tpgresource.ResourceDataMock, config *transport_tpg.Config, listTemplate, responseField string) ([]string, error)
ListParentResourcesInLocation calls a provided list endpoint and returns the names of any resources found in the response. This function is intended to be used in sweepers where the resources being swept can only be found with knowledge about existing parental resources.
func SharedConfigForRegion ¶
func SharedConfigForRegion(region string) (*transport_tpg.Config, error)
SharedConfigForRegion returns a common config setup needed for the sweeper functions for a given region
Types ¶
type Sweeper ¶
type Sweeper struct { // Name for sweeper. Must be unique to be ran by the Sweeper Runner Name string // Dependencies list the const names of other Sweeper functions that must be ran // prior to running this Sweeper. This is an ordered list that will be invoked // recursively at the helper/resource level Dependencies []string // Sweeper function that when invoked sweeps the Provider of specific // resources F SweeperFunc }
type SweeperFunc ¶
SweeperFunc is a signature for a function that acts as a sweeper. It accepts a string for the region that the sweeper is to be ran in. This function must be able to construct a valid client for that region.