[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78136WZ2THSXJZ0CHA24E79":3,"skill-same:01M78136WZ2THSXJZ0CHA24E79":71},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":31,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":34,"install":35,"resources":48},"01M78136WZ2THSXJZ0CHA24E79","provider-test-patterns",null,"Terraform provider acceptance test patterns using terraform-plugin-testing with the Plugin Framework. Covers test structure, TestCase\u002FTestStep fields, ConfigStateChecks with custom statecheck.StateCheck implementations, plan checks, CompareValue for cross-step assertions, config helpers, import testing with ImportStateKind, sweepers, and scenario patterns (basic, update, disappears, validation, regression), and ephemeral resource testing with the echoprovider package. Use when writing, reviewing, or debugging provider acceptance tests, including questions about statecheck, plancheck, TestCheckFunc, CheckDestroy, ExpectError, import state verification, ephemeral resources, or how to structure test files.","filippolmt\u002Fskills","filippolmt","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F61194571?v=4","01M7808VK1A8QF8ZXGT2DWTKHS","Filippo Merante Caparrotta","01M7808VKN74HC3EZMK8EV35KS",1,"MPL-2.0","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fplugins\u002Fpackages\u002Fprovider-test-patterns\u002Fskills\u002Fprovider-test-patterns\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fplugins\u002Fpackages\u002Fprovider-test-patterns\u002Fskills\u002Fprovider-test-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: provider-test-patterns\ndescription: >-\n  Terraform provider acceptance test patterns using terraform-plugin-testing\n  with the Plugin Framework. Covers test structure, TestCase\u002FTestStep fields,\n  ConfigStateChecks with custom statecheck.StateCheck implementations,\n  plan checks, CompareValue for cross-step assertions, config helpers,\n  import testing with ImportStateKind, sweepers, and scenario patterns\n  (basic, update, disappears, validation, regression), and ephemeral resource\n  testing with the echoprovider package. Use when writing, reviewing, or\n  debugging provider acceptance tests, including questions about statecheck,\n  plancheck, TestCheckFunc, CheckDestroy, ExpectError, import state\n  verification, ephemeral resources, or how to structure test files.\nmetadata:\n  copyright: Copyright IBM Corp. 2026\n  version: \"0.0.1\"\n---\n\n# Provider Acceptance Test Patterns\n\nPatterns for writing acceptance tests using\n[terraform-plugin-testing](https:\u002F\u002Fgithub.com\u002Fhashicorp\u002Fterraform-plugin-testing)\nwith the [Plugin Framework](https:\u002F\u002Fgithub.com\u002Fhashicorp\u002Fterraform-plugin-framework).\n\nSource: [HashiCorp Testing Patterns](https:\u002F\u002Fdeveloper.hashicorp.com\u002Fterraform\u002Fplugin\u002Ftesting\u002Ftesting-patterns)\n\n**References** (load when needed):\n- `references\u002Fchecks.md` — statecheck, plancheck, knownvalue types, tfjsonpath, comparers\n- `references\u002Fsweepers.md` — sweeper setup, TestMain, dependencies\n- `references\u002Fephemeral.md` — ephemeral resource testing, echoprovider, multi-step patterns\n\n---\n\n## Test Lifecycle\n\nThe framework runs each TestStep through: **plan → apply → refresh → final\nplan**. If the final plan shows a diff, the test fails (unless\n`ExpectNonEmptyPlan` is set). After all steps, destroy runs followed by\n`CheckDestroy`. This means every test automatically verifies that\nconfigurations apply cleanly and produce no drift — no assertions needed for\nthat.\n\n---\n\n## Test Function Structure\n\n```go\nfunc TestAccExample_basic(t *testing.T) {\n    var widget example.Widget\n    rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)\n    resourceName := \"example_widget.test\"\n\n    resource.ParallelTest(t, resource.TestCase{\n        PreCheck:                 func() { testAccPreCheck(t) },\n        ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,\n        CheckDestroy:             testAccCheckExampleDestroy,\n        Steps: []resource.TestStep{\n            {\n                Config: testAccExampleConfig_basic(rName),\n                ConfigStateChecks: []statecheck.StateCheck{\n                    stateCheckExampleExists(resourceName, &widget),\n                    statecheck.ExpectKnownValue(resourceName,\n                        tfjsonpath.New(\"name\"), knownvalue.StringExact(rName)),\n                    statecheck.ExpectKnownValue(resourceName,\n                        tfjsonpath.New(\"id\"), knownvalue.NotNull()),\n                },\n            },\n        },\n    })\n}\n```\n\nUse `resource.ParallelTest` by default. Use `resource.Test` only when tests\nshare state or cannot run concurrently.\n\n---\n\n## Provider Factory\n\n```go\n\u002F\u002F provider_test.go — Plugin Framework with Protocol 6 (use Protocol5 variant if needed)\nvar testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){\n    \"example\": providerserver.NewProtocol6WithError(New(\"test\")()),\n}\n```\n\n---\n\n## TestCase Fields\n\n| Field | Purpose |\n|-------|---------|\n| `PreCheck` | `func()` — verify prerequisites (env vars, API access) |\n| `ProtoV6ProviderFactories` | Plugin Framework provider factories |\n| `CheckDestroy` | `TestCheckFunc` — verify resources destroyed after all steps |\n| `Steps` | `[]TestStep` — sequential test operations |\n| `TerraformVersionChecks` | `[]tfversion.TerraformVersionCheck` — gate by CLI version |\n\n---\n\n## TestStep Fields\n\n### Config Mode\n\n| Field | Purpose |\n|-------|---------|\n| `Config` | Inline HCL string to apply |\n| `ConfigStateChecks` | `[]statecheck.StateCheck` — modern assertions (preferred) |\n| `ConfigPlanChecks` | `resource.ConfigPlanChecks{PreApply: []plancheck.PlanCheck{...}}` |\n| `ExpectError` | `*regexp.Regexp` — expect failure matching pattern |\n| `ExpectNonEmptyPlan` | `bool` — expect non-empty plan after apply |\n| `PlanOnly` | `bool` — plan without applying |\n| `Destroy` | `bool` — run destroy step |\n| `PreConfig` | `func()` — setup before step |\n\n### Import Mode\n\n| Field | Purpose |\n|-------|---------|\n| `ImportState` | `true` to enable import mode |\n| `ImportStateVerify` | Verify imported state matches prior state |\n| `ImportStateVerifyIgnore` | `[]string` — attributes to skip during verify |\n| `ImportStateKind` | `resource.ImportBlockWithID` — import block generation |\n| `ResourceName` | Resource address to import |\n| `ImportStateId` | Override the ID used for import |\n\n---\n\n## Check Functions\n\n### Modern: ConfigStateChecks (preferred)\n\nType-safe with aggregated error reporting. Compose built-in checks with custom\n`statecheck.StateCheck` implementations. See `references\u002Fchecks.md` for full\nknownvalue types, tfjsonpath navigation, and comparers.\n\n```go\nConfigStateChecks: []statecheck.StateCheck{\n    stateCheckExampleExists(resourceName, &widget),\n    statecheck.ExpectKnownValue(resourceName,\n        tfjsonpath.New(\"name\"), knownvalue.StringExact(\"my-widget\")),\n    statecheck.ExpectKnownValue(resourceName,\n        tfjsonpath.New(\"enabled\"), knownvalue.Bool(true)),\n    statecheck.ExpectKnownValue(resourceName,\n        tfjsonpath.New(\"id\"), knownvalue.NotNull()),\n    statecheck.ExpectSensitiveValue(resourceName,\n        tfjsonpath.New(\"api_key\")),\n},\n```\n\nDo not mix `Check` (legacy) and `ConfigStateChecks` in the same step.\n\n### Legacy: Check (for CheckDestroy and migration)\n\n`CheckDestroy` on `TestCase` requires `TestCheckFunc`. The `Check` field on\n`TestStep` also accepts `TestCheckFunc` but prefer `ConfigStateChecks` for new\ntests.\n\n```go\nCheck: resource.ComposeAggregateTestCheckFunc(\n    resource.TestCheckResourceAttr(name, \"key\", \"expected\"),\n    resource.TestCheckResourceAttrSet(name, \"id\"),\n    resource.TestCheckNoResourceAttr(name, \"removed\"),\n    resource.TestMatchResourceAttr(name, \"url\", regexp.MustCompile(`^https:\u002F\u002F`)),\n    resource.TestCheckResourceAttrPair(res1, \"ref_id\", res2, \"id\"),\n),\n```\n\n`ComposeAggregateTestCheckFunc` reports all errors; `ComposeTestCheckFunc`\nfails fast on the first.\n\n---\n\n## Config Helpers\n\nUse numbered format verbs — `%[1]q` for quoted strings, `%[1]s` for raw:\n\n```go\nfunc testAccExampleConfig_basic(rName string) string {\n    return fmt.Sprintf(`\nresource \"example_widget\" \"test\" {\n  name = %[1]q\n}\n`, rName)\n}\n\nfunc testAccExampleConfig_full(rName, description string) string {\n    return fmt.Sprintf(`\nresource \"example_widget\" \"test\" {\n  name        = %[1]q\n  description = %[2]q\n  enabled     = true\n}\n`, rName, description)\n}\n```\n\n---\n\n## Scenario Patterns\n\n### Basic + Update (combine in one test — updates are supersets of basic)\n\n```go\nSteps: []resource.TestStep{\n    {\n        Config: testAccExampleConfig_basic(rName),\n        ConfigStateChecks: []statecheck.StateCheck{\n            stateCheckExampleExists(resourceName, &widget),\n            statecheck.ExpectKnownValue(resourceName,\n                tfjsonpath.New(\"name\"), knownvalue.StringExact(rName)),\n        },\n    },\n    {\n        Config: testAccExampleConfig_full(rName, \"updated\"),\n        ConfigStateChecks: []statecheck.StateCheck{\n            stateCheckExampleExists(resourceName, &widget),\n            statecheck.ExpectKnownValue(resourceName,\n                tfjsonpath.New(\"description\"), knownvalue.StringExact(\"updated\")),\n        },\n    },\n},\n```\n\n### Import\n\nAfter a config step, verify import produces identical state. Use\n`ImportStateKind` for import block generation:\n\n```go\n{\n    ResourceName:      resourceName,\n    ImportState:       true,\n    ImportStateVerify: true,\n    ImportStateKind:   resource.ImportBlockWithID,\n},\n```\n\n### Disappears (resource deleted externally)\n\n```go\n{\n    Config: testAccExampleConfig_basic(rName),\n    ConfigStateChecks: []statecheck.StateCheck{\n        stateCheckExampleExists(resourceName, &widget),\n        stateCheckExampleDisappears(resourceName),\n    },\n    ExpectNonEmptyPlan: true,\n},\n```\n\n### Validation (expect error)\n\n```go\n{\n    Config:      testAccExampleConfig_invalidName(\"\"),\n    ExpectError: regexp.MustCompile(`name must not be empty`),\n},\n```\n\n### Regression (two-commit workflow)\n\nA proper bug fix uses at least two commits: first commit the regression test\n(which fails, confirming the bug), then commit the fix (test passes). This\nlets reviewers independently verify the test reproduces the issue by checking\nout the first commit, then advancing to the fix.\n\nName and document regression tests to identify the issue they fix. Include a\nlink to the original bug report when possible.\n\n```go\n\u002F\u002F TestAccExample_regressionGH1234 verifies fix for https:\u002F\u002Fgithub.com\u002Forg\u002Frepo\u002Fissues\u002F1234\nfunc TestAccExample_regressionGH1234(t *testing.T) {\n    rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)\n    resourceName := \"example_widget.test\"\n\n    resource.ParallelTest(t, resource.TestCase{\n        PreCheck:                 func() { testAccPreCheck(t) },\n        ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,\n        CheckDestroy:             testAccCheckExampleDestroy,\n        Steps: []resource.TestStep{\n            {\n                \u002F\u002F Reproduce the issue: this config triggered the bug\n                Config: testAccExampleConfig_regressionGH1234(rName),\n                ConfigStateChecks: []statecheck.StateCheck{\n                    stateCheckExampleExists(resourceName, nil),\n                    statecheck.ExpectKnownValue(resourceName,\n                        tfjsonpath.New(\"computed_field\"), knownvalue.NotNull()),\n                },\n            },\n        },\n    })\n}\n```\n\n---\n\n## Helper Functions\n\n### Custom StateCheck: Exists\n\nImplement `statecheck.StateCheck` for API existence verification. Separate the\nexists check into its own function for reuse across steps — the source\nrecommends this as a design principle:\n\n```go\ntype exampleExistsCheck struct {\n    resourceAddress string\n    widget          *example.Widget\n}\n\nfunc (e exampleExistsCheck) CheckState(ctx context.Context, req statecheck.CheckStateRequest, resp *statecheck.CheckStateResponse) {\n    r, err := stateResourceAtAddress(req.State, e.resourceAddress)\n    if err != nil {\n        resp.Error = err\n        return\n    }\n\n    id, ok := r.AttributeValues[\"id\"].(string)\n    if !ok {\n        resp.Error = fmt.Errorf(\"no id found for %s\", e.resourceAddress)\n        return\n    }\n\n    conn := testAccAPIClient()\n    widget, err := conn.GetWidget(id)\n    if err != nil {\n        resp.Error = fmt.Errorf(\"%s not found via API: %w\", e.resourceAddress, err)\n        return\n    }\n\n    if e.widget != nil {\n        *e.widget = *widget\n    }\n}\n\nfunc stateCheckExampleExists(name string, widget *example.Widget) statecheck.StateCheck {\n    return exampleExistsCheck{resourceAddress: name, widget: widget}\n}\n```\n\n### Custom StateCheck: Disappears\n\nDelete a resource via API to simulate external deletion:\n\n```go\ntype exampleDisappearsCheck struct {\n    resourceAddress string\n}\n\nfunc (e exampleDisappearsCheck) CheckState(ctx context.Context, req statecheck.CheckStateRequest, resp *statecheck.CheckStateResponse) {\n    r, err := stateResourceAtAddress(req.State, e.resourceAddress)\n    if err != nil {\n        resp.Error = err\n        return\n    }\n\n    id := r.AttributeValues[\"id\"].(string)\n    conn := testAccAPIClient()\n    resp.Error = conn.DeleteWidget(id)\n}\n\nfunc stateCheckExampleDisappears(name string) statecheck.StateCheck {\n    return exampleDisappearsCheck{resourceAddress: name}\n}\n```\n\n### State Resource Lookup (shared utility)\n\n```go\nfunc stateResourceAtAddress(state *tfjson.State, address string) (*tfjson.StateResource, error) {\n    if state == nil || state.Values == nil || state.Values.RootModule == nil {\n        return nil, fmt.Errorf(\"no state available\")\n    }\n    for _, r := range state.Values.RootModule.Resources {\n        if r.Address == address {\n            return r, nil\n        }\n    }\n    return nil, fmt.Errorf(\"not found in state: %s\", address)\n}\n```\n\n### Destroy Check (TestCheckFunc — required by CheckDestroy)\n\n```go\nfunc testAccCheckExampleDestroy(s *terraform.State) error {\n    conn := testAccAPIClient()\n    for _, rs := range s.RootModule().Resources {\n        if rs.Type != \"example_widget\" {\n            continue\n        }\n        _, err := conn.GetWidget(rs.Primary.ID)\n        if err == nil {\n            return fmt.Errorf(\"widget %s still exists\", rs.Primary.ID)\n        }\n        if !isNotFoundError(err) {\n            return err\n        }\n    }\n    return nil\n}\n```\n\n### PreCheck\n\n```go\nfunc testAccPreCheck(t *testing.T) {\n    t.Helper()\n    if os.Getenv(\"EXAMPLE_API_KEY\") == \"\" {\n        t.Fatal(\"EXAMPLE_API_KEY must be set for acceptance tests\")\n    }\n}\n```\n","# Provider Acceptance Test Patterns\n\nPatterns for writing acceptance tests using\n[terraform-plugin-testing](https:\u002F\u002Fgithub.com\u002Fhashicorp\u002Fterraform-plugin-testing)\nwith the [Plugin Framework](https:\u002F\u002Fgithub.com\u002Fhashicorp\u002Fterraform-plugin-framework).\n\nSource: [HashiCorp Testing Patterns](https:\u002F\u002Fdeveloper.hashicorp.com\u002Fterraform\u002Fplugin\u002Ftesting\u002Ftesting-patterns)\n\n**References** (load when needed):\n- `references\u002Fchecks.md` — statecheck, plancheck, knownvalue types, tfjsonpath, comparers\n- `references\u002Fsweepers.md` — sweeper setup, TestMain, dependencies\n- `references\u002Fephemeral.md` — ephemeral resource testing, echoprovider, multi-step patterns\n\n---\n\n## Test Lifecycle\n\nThe framework runs each TestStep through: **plan → apply → refresh → final\nplan**. If the final plan shows a diff, the test fails (unless\n`ExpectNonEmptyPlan` is set). After all steps, destroy runs followed by\n`CheckDestroy`. This means every test automatically verifies that\nconfigurations apply cleanly and produce no drift — no assertions needed for\nthat.\n\n---\n\n## Test Function Structure\n\n```go\nfunc TestAccExample_basic(t *testing.T) {\n    var widget example.Widget\n    rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)\n    resourceName := \"example_widget.test\"\n\n    resource.ParallelTest(t, resource.TestCase{\n        PreCheck:                 func() { testAccPreCheck(t) },\n        ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,\n        CheckDestroy:             testAccCheckExampleDestroy,\n        Steps: []resource.TestStep{\n            {\n                Config: testAccExampleConfig_basic(rName),\n                ConfigStateChecks: []statecheck.StateCheck{\n                    stateCheckExampleExists(resourceName, &widget),\n                    statecheck.ExpectKnownValue(resourceName,\n                        tfjsonpath.New(\"name\"), knownvalue.StringExact(rName)),\n                    statecheck.ExpectKnownValue(resourceName,\n                        tfjsonpath.New(\"id\"), knownvalue.NotNull()),\n                },\n            },\n        },\n    })\n}\n```\n\nUse `resource.ParallelTest` by default. Use `resource.Test` only when tests\nshare state or cannot run concurrently.\n\n---\n\n## Provider Factory\n\n```go\n\u002F\u002F provider_test.go — Plugin Framework with Protocol 6 (use Protocol5 variant if needed)\nvar testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){\n    \"example\": providerserver.NewProtocol6WithError(New(\"test\")()),\n}\n```\n\n---\n\n## TestCase Fields\n\n| Field | Purpose |\n|-------|---------|\n| `PreCheck` | `func()` — verify prerequisites (env vars, API access) |\n| `ProtoV6ProviderFactories` | Plugin Framework provider factories |\n| `CheckDestroy` | `TestCheckFunc` — verify resources destroyed after all steps |\n| `Steps` | `[]TestStep` — sequential test operations |\n| `TerraformVersionChecks` | `[]tfversion.TerraformVersionCheck` — gate by CLI version |\n\n---\n\n## TestStep Fields\n\n### Config Mode\n\n| Field | Purpose |\n|-------|---------|\n| `Config` | Inline HCL string to apply |\n| `ConfigStateChecks` | `[]statecheck.StateCheck` — modern assertions (preferred) |\n| `ConfigPlanChecks` | `resource.ConfigPlanChecks{PreApply: []plancheck.PlanCheck{...}}` |\n| `ExpectError` | `*regexp.Regexp` — expect failure matching pattern |\n| `ExpectNonEmptyPlan` | `bool` — expect non-empty plan after apply |\n| `PlanOnly` | `bool` — plan without applying |\n| `Destroy` | `bool` — run destroy step |\n| `PreConfig` | `func()` — setup before step |\n\n### Import Mode\n\n| Field | Purpose |\n|-------|---------|\n| `ImportState` | `true` to enable import mode |\n| `ImportStateVerify` | Verify imported state matches prior state |\n| `ImportStateVerifyIgnore` | `[]string` — attributes to skip during verify |\n| `ImportStateKind` | `resource.ImportBlockWithID` — import block generation |\n| `ResourceName` | Resource address to import |\n| `ImportStateId` | Override the ID used for import |\n\n---\n\n## Check Functions\n\n### Modern: ConfigStateChecks (preferred)\n\nType-safe with aggregated error reporting. Compose built-in checks with custom\n`statecheck.StateCheck` implementations. See `references\u002Fchecks.md` for full\nknownvalue types, tfjsonpath navigation, and comparers.\n\n```go\nConfigStateChecks: []statecheck.StateCheck{\n    stateCheckExampleExists(resourceName, &widget),\n    statecheck.ExpectKnownValue(resourceName,\n        tfjsonpath.New(\"name\"), knownvalue.StringExact(\"my-widget\")),\n    statecheck.ExpectKnownValue(resourceName,\n        tfjsonpath.New(\"enabled\"), knownvalue.Bool(true)),\n    statecheck.ExpectKnownValue(resourceName,\n        tfjsonpath.New(\"id\"), knownvalue.NotNull()),\n    statecheck.ExpectSensitiveValue(resourceName,\n        tfjsonpath.New(\"api_key\")),\n},\n```\n\nDo not mix `Check` (legacy) and `ConfigStateChecks` in the same step.\n\n### Legacy: Check (for CheckDestroy and migration)\n\n`CheckDestroy` on `TestCase` requires `TestCheckFunc`. The `Check` field on\n`TestStep` also accepts `TestCheckFunc` but prefer `ConfigStateChecks` for new\ntests.\n\n```go\nCheck: resource.ComposeAggregateTestCheckFunc(\n    resource.TestCheckResourceAttr(name, \"key\", \"expected\"),\n    resource.TestCheckResourceAttrSet(name, \"id\"),\n    resource.TestCheckNoResourceAttr(name, \"removed\"),\n    resource.TestMatchResourceAttr(name, \"url\", regexp.MustCompile(`^https:\u002F\u002F`)),\n    resource.TestCheckResourceAttrPair(res1, \"ref_id\", res2, \"id\"),\n),\n```\n\n`ComposeAggregateTestCheckFunc` reports all errors; `ComposeTestCheckFunc`\nfails fast on the first.\n\n---\n\n## Config Helpers\n\nUse numbered format verbs — `%[1]q` for quoted strings, `%[1]s` for raw:\n\n```go\nfunc testAccExampleConfig_basic(rName string) string {\n    return fmt.Sprintf(`\nresource \"example_widget\" \"test\" {\n  name = %[1]q\n}\n`, rName)\n}\n\nfunc testAccExampleConfig_full(rName, description string) string {\n    return fmt.Sprintf(`\nresource \"example_widget\" \"test\" {\n  name        = %[1]q\n  description = %[2]q\n  enabled     = true\n}\n`, rName, description)\n}\n```\n\n---\n\n## Scenario Patterns\n\n### Basic + Update (combine in one test — updates are supersets of basic)\n\n```go\nSteps: []resource.TestStep{\n    {\n        Config: testAccExampleConfig_basic(rName),\n        ConfigStateChecks: []statecheck.StateCheck{\n            stateCheckExampleExists(resourceName, &widget),\n            statecheck.ExpectKnownValue(resourceName,\n                tfjsonpath.New(\"name\"), knownvalue.StringExact(rName)),\n        },\n    },\n    {\n        Config: testAccExampleConfig_full(rName, \"updated\"),\n        ConfigStateChecks: []statecheck.StateCheck{\n            stateCheckExampleExists(resourceName, &widget),\n            statecheck.ExpectKnownValue(resourceName,\n                tfjsonpath.New(\"description\"), knownvalue.StringExact(\"updated\")),\n        },\n    },\n},\n```\n\n### Import\n\nAfter a config step, verify import produces identical state. Use\n`ImportStateKind` for import block generation:\n\n```go\n{\n    ResourceName:      resourceName,\n    ImportState:       true,\n    ImportStateVerify: true,\n    ImportStateKind:   resource.ImportBlockWithID,\n},\n```\n\n### Disappears (resource deleted externally)\n\n```go\n{\n    Config: testAccExampleConfig_basic(rName),\n    ConfigStateChecks: []statecheck.StateCheck{\n        stateCheckExampleExists(resourceName, &widget),\n        stateCheckExampleDisappears(resourceName),\n    },\n    ExpectNonEmptyPlan: true,\n},\n```\n\n### Validation (expect error)\n\n```go\n{\n    Config:      testAccExampleConfig_invalidName(\"\"),\n    ExpectError: regexp.MustCompile(`name must not be empty`),\n},\n```\n\n### Regression (two-commit workflow)\n\nA proper bug fix uses at least two commits: first commit the regression test\n(which fails, confirming the bug), then commit the fix (test passes). This\nlets reviewers independently verify the test reproduces the issue by checking\nout the first commit, then advancing to the fix.\n\nName and document regression tests to identify the issue they fix. Include a\nlink to the original bug report when possible.\n\n```go\n\u002F\u002F TestAccExample_regressionGH1234 verifies fix for https:\u002F\u002Fgithub.com\u002Forg\u002Frepo\u002Fissues\u002F1234\nfunc TestAccExample_regressionGH1234(t *testing.T) {\n    rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)\n    resourceName := \"example_widget.test\"\n\n    resource.ParallelTest(t, resource.TestCase{\n        PreCheck:                 func() { testAccPreCheck(t) },\n        ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,\n        CheckDestroy:             testAccCheckExampleDestroy,\n        Steps: []resource.TestStep{\n            {\n                \u002F\u002F Reproduce the issue: this config triggered the bug\n                Config: testAccExampleConfig_regressionGH1234(rName),\n                ConfigStateChecks: []statecheck.StateCheck{\n                    stateCheckExampleExists(resourceName, nil),\n                    statecheck.ExpectKnownValue(resourceName,\n                        tfjsonpath.New(\"computed_field\"), knownvalue.NotNull()),\n                },\n            },\n        },\n    })\n}\n```\n\n---\n\n## Helper Functions\n\n### Custom StateCheck: Exists\n\nImplement `statecheck.StateCheck` for API existence verification. Separate the\nexists check into its own function for reuse across steps — the source\nrecommends this as a design principle:\n\n```go\ntype exampleExistsCheck struct {\n    resourceAddress string\n    widget          *example.Widget\n}\n\nfunc (e exampleExistsCheck) CheckState(ctx context.Context, req statecheck.CheckStateRequest, resp *statecheck.CheckStateResponse) {\n    r, err := stateResourceAtAddress(req.State, e.resourceAddress)\n    if err != nil {\n        resp.Error = err\n        return\n    }\n\n    id, ok := r.AttributeValues[\"id\"].(string)\n    if !ok {\n        resp.Error = fmt.Errorf(\"no id found for %s\", e.resourceAddress)\n        return\n    }\n\n    conn := testAccAPIClient()\n    widget, err := conn.GetWidget(id)\n    if err != nil {\n        resp.Error = fmt.Errorf(\"%s not found via API: %w\", e.resourceAddress, err)\n        return\n    }\n\n    if e.widget != nil {\n        *e.widget = *widget\n    }\n}\n\nfunc stateCheckExampleExists(name string, widget *example.Widget) statecheck.StateCheck {\n    return exampleExistsCheck{resourceAddress: name, widget: widget}\n}\n```\n\n### Custom StateCheck: Disappears\n\nDelete a resource via API to simulate external deletion:\n\n```go\ntype exampleDisappearsCheck struct {\n    resourceAddress string\n}\n\nfunc (e exampleDisappearsCheck) CheckState(ctx context.Context, req statecheck.CheckStateRequest, resp *statecheck.CheckStateResponse) {\n    r, err := stateResourceAtAddress(req.State, e.resourceAddress)\n    if err != nil {\n        resp.Error = err\n        return\n    }\n\n    id := r.AttributeValues[\"id\"].(string)\n    conn := testAccAPIClient()\n    resp.Error = conn.DeleteWidget(id)\n}\n\nfunc stateCheckExampleDisappears(name string) statecheck.StateCheck {\n    return exampleDisappearsCheck{resourceAddress: name}\n}\n```\n\n### State Resource Lookup (shared utility)\n\n```go\nfunc stateResourceAtAddress(state *tfjson.State, address string) (*tfjson.StateResource, error) {\n    if state == nil || state.Values == nil || state.Values.RootModule == nil {\n        return nil, fmt.Errorf(\"no state available\")\n    }\n    for _, r := range state.Values.RootModule.Resources {\n        if r.Address == address {\n            return r, nil\n        }\n    }\n    return nil, fmt.Errorf(\"not found in state: %s\", address)\n}\n```\n\n### Destroy Check (TestCheckFunc — required by CheckDestroy)\n\n```go\nfunc testAccCheckExampleDestroy(s *terraform.State) error {\n    conn := testAccAPIClient()\n    for _, rs := range s.RootModule().Resources {\n        if rs.Type != \"example_widget\" {\n            continue\n        }\n        _, err := conn.GetWidget(rs.Primary.ID)\n        if err == nil {\n            return fmt.Errorf(\"widget %s still exists\", rs.Primary.ID)\n        }\n        if !isNotFoundError(err) {\n            return err\n        }\n    }\n    return nil\n}\n```\n\n### PreCheck\n\n```go\nfunc testAccPreCheck(t *testing.T) {\n    t.Helper()\n    if os.Getenv(\"EXAMPLE_API_KEY\") == \"\" {\n        t.Fatal(\"EXAMPLE_API_KEY must be set for acceptance tests\")\n    }\n}\n```\n",{"name":5,"metadata":25,"description":7},{"version":26,"copyright":27},"0.0.1","Copyright IBM Corp. 2026","main","e63612d78f9099c1970584ea3faef109f42d20bb",".agents\u002Fplugins\u002Fpackages\u002Fprovider-test-patterns\u002Fskills\u002Fprovider-test-patterns",0,"https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills","https:\u002F\u002Fgithub.com\u002Ffilippolmt","2026-11-14 22:46:00",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add filippolmt\u002Fskills --skill provider-test-patterns",{"tool":41,"command":42},"bunx","bunx skills add filippolmt\u002Fskills --skill provider-test-patterns",{"tool":44,"command":45},"pnpm","pnpm dlx skills add filippolmt\u002Fskills --skill provider-test-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fplugins\u002Fpackages\u002Fprovider-test-patterns\u002Fskills\u002Fprovider-test-patterns\u002FSKILL.md",true,[49,53,59,63,67],{"path":50,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":16},"LICENSE","许可证",16726,{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Fchecks.md","REFERENCE","参考文档",6844,"https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fplugins\u002Fpackages\u002Fprovider-test-patterns\u002Fskills\u002Fprovider-test-patterns\u002Freferences\u002Fchecks.md",{"path":60,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fephemeral.md",6002,"https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fplugins\u002Fpackages\u002Fprovider-test-patterns\u002Fskills\u002Fprovider-test-patterns\u002Freferences\u002Fephemeral.md",{"path":64,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fsweepers.md",2403,"https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fplugins\u002Fpackages\u002Fprovider-test-patterns\u002Fskills\u002Fprovider-test-patterns\u002Freferences\u002Fsweepers.md",{"path":68,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":69,"sourceHtmlUrl":70},"SOURCE.md",452,"https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fplugins\u002Fpackages\u002Fprovider-test-patterns\u002Fskills\u002Fprovider-test-patterns\u002FSOURCE.md",[72,81,90,98,106,114],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":77,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":20},"01M781ZJN9KDK0YY8EAQ8WXPRQ","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","MIT","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-for-agents\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":86,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":20},"01M781ZDZ8CQ30GRY5XNT1RF91","wrangler","Run or troubleshoot Wrangler CLI commands in projects that have a wrangler.jsonc, wrangler.json, or wrangler.toml file, including local development, Previews, deployment, and resource management. For new projects and projects without a Wrangler configuration file, use the cf CLI instead.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwrangler\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwrangler\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":94,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":20},"01M781ZA1MB7E7T1R1TE0BTTJS","workers-profiling","Profile or debug CPU usage and memory allocation in deployed Cloudflare Workers and Durable Objects. Then use this information to optimize your code.","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fworkers-profiling\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fworkers-profiling\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":102,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":20},"01M781Z52Q7PBMDA2YBC3SCTYM","workers-development","Run, inspect, and debug Cloudflare Workers during local development with cf dev, wrangler dev, or the Cloudflare Vite plugin, using Local Explorer to read and seed binding data and query local traces and logs. Also routes production debugging to Workers observability. Use for debugging requests whether or not the project uses Wrangler.","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fworkers-development\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fworkers-development\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":85,"licenseFileUrl":110,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":20},"01M781Z193MG7SHF4DSD1WK583","workers-best-practices","Cloudflare Workers best practices for production applications. Use when writing, reviewing, or configuring Workers.","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fworkers-best-practices\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fworkers-best-practices\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":118,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":20},"01M781YT0JB3GVA1HTFZ9QJHM7","wordpress-pro","Develops custom WordPress themes and plugins, creates and registers Gutenberg blocks and block patterns, configures WooCommerce stores, implements WordPress REST API endpoints, applies security hardening (nonces, sanitization, escaping, capability checks), and optimizes performance through caching and query tuning. Use when building WordPress themes, writing plugins, customizing Gutenberg blocks, extending WooCommerce, working with ACF, using the WordPress REST API, applying hooks and filters, or improving WordPress performance and security.","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwordpress-pro\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Ffilippolmt\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fwordpress-pro\u002FSKILL.md",[],[]]