Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateRandomResourceName() stringdeprecated
- func IsTestResourceName(name string) bool
- func ProviderFactories(customHeader http.Header) map[string]func() (tfprotov6.ProviderServer, error)
- func ResourceName(slug string) string
- func ResourceNameRaw(name string) string
- func SGClient() *sgclient.Client
- func SweepDryRun() bool
- func SweepEnabled() bool
- func TFStandardErrorPattern(msg string) *regexp.Regexp
- func TestAccPreCheck(t *testing.T)
- type SweepReport
Constants ¶
const ( // NamePrefix marks every identifier these tests create. Randomising a name // stops a failed cleanup from blocking the next run, but on its own it turns // each leak into an unattributable resource nobody dares delete. The shared // prefix is what makes leaks identifiable afterwards -- by the sweeper, by a // dashboard filter, or by a human deciding what is safe to remove. NamePrefix = "tfacc" )
Variables ¶
var SweepUnsupported = []string{
"policies (sg-sdk-go ListAllPolicies discards the response body)",
"roles (sg-sdk-go ListAllRoles discards the response body)",
"runner groups (sg-sdk-go exposes no list method)",
}
SweepUnsupported names the resource types a sweep cannot reach, so the caller can say so rather than implying the organisation is clean.
Functions ¶
func GenerateRandomResourceName
deprecated
func GenerateRandomResourceName() string
GenerateRandomResourceName builds a unique-ish resource identifier to use in tests.
Deprecated: prefer ResourceName, whose output carries the shared prefix and so can be recognised and swept up after a failed run.
func IsTestResourceName ¶ added in v1.12.2
IsTestResourceName reports whether a name looks like one this suite created. Sweepers use it to decide what is safe to delete, so it is deliberately strict: anything not carrying the prefix is left alone.
func ProviderFactories ¶
func ResourceName ¶ added in v1.12.2
ResourceName returns a unique identifier for one acceptance-test resource, shaped as "tfacc-<slug>-<random>".
Static names made the suite order-dependent: a run that failed before its destroy step left the name taken, and every later run failed at create with 409 "already exists" until somebody deleted it by hand. A fresh name per run removes that coupling.
The slug is kept so a leaked resource still says which test made it.
func ResourceNameRaw ¶ added in v1.12.2
ResourceNameRaw makes a name unique without cleaning it up, for the tests whose subject is an awkward name: one carrying spaces, capitals, or punctuation the platform has to cope with. Sanitising those would leave the test passing while removing the thing it checks.
The prefix and random part lead so the result is still recognisable to IsTestResourceName and to a sweeper.
func SweepDryRun ¶ added in v1.12.2
func SweepDryRun() bool
SweepDryRun reports whether the sweep should only describe what it would do.
func SweepEnabled ¶ added in v1.12.2
func SweepEnabled() bool
SweepEnabled reports whether the caller asked for a cleanup pass rather than a normal test run. Kept separate from the sweeper implementations so a package can guard destructive helpers behind it.
func TFStandardErrorPattern ¶ added in v1.12.2
TFStandardErrorPattern builds a regexp for resource.TestStep.ExpectError from a literal error message. Terraform's CLI hard-wraps diagnostic text at a fixed column width, so a long message can come back with newlines inserted between words (e.g. "TERRAFORM or\nOPENTOFU" instead of "TERRAFORM or OPENTOFU") — a pattern built with literal spaces silently fails to match whenever a wrap happens to land inside it. This quotes every word and joins them with \s+, so the match tolerates a line break (or any other run of whitespace) wherever the CLI happens to wrap.
func TestAccPreCheck ¶
Types ¶
type SweepReport ¶ added in v1.12.2
SweepReport accumulates what a sweep found.
func Sweep ¶ added in v1.12.2
Sweep removes every test-created resource it can reach in org. It continues past individual failures: one resource that refuses to delete should not hide the rest.
func (*SweepReport) String ¶ added in v1.12.2
func (r *SweepReport) String() string