Community生產力與協作github.com

hashicorp/provider-test-patterns

使用 terraform-plugin-testing 搭配 Plugin Framework 的 Terraform Provider 接受度測試模式。涵蓋測試結構、TestCase/TestStep 欄位、自訂 statecheck.StateCheck 實作的 ConfigStateChecks、計畫檢查、跨步驟斷言的 CompareValue、設定輔助函式、使用 ImportStateKind 的匯入測試、sweepers,以及情境模式(基本、更新、消失、驗證、回歸)和使用 echoprovider 套件的短暫資源測試。

provider-test-patterns 是什麼?

這個技能針對使用 terraform-plugin-testing 和 Plugin Framework 編寫、審查或除錯 Terraform Provider 接受度測試的開發者。它提供一套全面的模式與最佳實務,涵蓋測試結構、TestCase 和 TestStep 欄位的設定,以及如何實作自訂的 statecheck.StateCheck 來進行配置狀態檢查。技能也深入說明如何使用 plancheck 進行計畫層級的斷言、使用 CompareValue 進行跨步驟的值比較,以及運用設定輔助函式來建立可重複使用的測試元件。此外,它包含匯入測試(使用 ImportStateKind)、sweepers 和基本情境模式(如基本、更新、消失、驗證和回歸)的指導。對於使用 echoprovider 套件的短暫資源測試,技能也提供特定模式。支援的查詢範疇包括 statecheck、plancheck、TestCheckFunc、CheckDestroy、ExpectError、匯入狀態驗證,以及測試檔案的組織方式,這使其成為撰寫可靠 Terraform Provider 測試的必備參考。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/hashicorp/agent-skills/tree/main/skills/provider-test-patterns

Installed? Explore more 生產力與協作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

provider-test-patterns 是做什麼的?

使用 terraform-plugin-testing 搭配 Plugin Framework 的 Terraform Provider 接受度測試模式。涵蓋測試結構、TestCase/TestStep 欄位、自訂 statecheck.StateCheck 實作的 ConfigStateChecks、計畫檢查、跨步驟斷言的 CompareValue、設定輔助函式、使用 ImportStateKind 的匯入測試、sweepers,以及情境模式(基本、更新、消失、驗證、回歸)和使用 echoprovider 套件的短暫資源測試。在編寫、審查或除錯 Provider 接受度測試時使用,包含關於 statecheck、plancheck、TestCheckFunc、CheckDestroy、ExpectError、匯入狀態驗證、短暫資源或如何結構化測試檔案的問題。

Individual skills in this repo

This repo contains 15 individual skills — each has its own dedicated page.

hashicorp/aws-ami-builder

Build Amazon Machine Images (AMIs) with Packer using the amazon-ebs builder. Use when creating custom AMIs for EC2 instances.

hashicorp/azure-image-builder

Build Azure managed images and Azure Compute Gallery images with Packer. Use when creating custom images for Azure VMs.

hashicorp/azure-verified-modules

Azure Verified Modules (AVM) requirements and best practices for developing certified Azure Terraform modules. Use when creating or reviewing Azure modules that need AVM certification.

hashicorp/new-terraform-provider

Use this when scaffolding a new Terraform provider.

hashicorp/provider-actions

Implement Terraform Provider actions using the Plugin Framework. Use when developing imperative operations that execute at lifecycle events (before/after create, update, destroy).

hashicorp/provider-docs

Create, update, and review Terraform provider documentation for Terraform Registry using HashiCorp-recommended patterns, tfplugindocs templates, and schema descriptions. Use when adding or changing provider configuration, resources, data sources, ephemeral resources, list resources, functions, or guides; when validating generated docs; and when troubleshooting missing or incorrect Registry documentation.

hashicorp/provider-resources

Implement Terraform Provider resources and data sources using the Plugin Framework. Use when developing CRUD operations, schema design, state management, and acceptance testing for provider resources.

hashicorp/push-to-registry

Push Packer build metadata to HCP Packer registry for tracking and managing image lifecycle. Use when integrating Packer builds with HCP Packer for version control and governance.

hashicorp/refactor-module

Transform monolithic Terraform configurations into reusable, maintainable modules following HashiCorp's module design principles and community best practices.

hashicorp/run-acceptance-tests

Guide for running acceptance tests for a Terraform provider. Use this when asked to run an acceptance test or to run a test with the prefix `TestAcc`.

hashicorp/terraform-search-import

Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management. Use when bringing unmanaged infrastructure under Terraform control, auditing cloud resources, or migrating to IaC.

hashicorp/terraform-stacks

Comprehensive guide for working with HashiCorp Terraform Stacks. Use when creating, modifying, or validating Terraform Stack configurations (.tfcomponent.hcl, .tfdeploy.hcl files), working with stack components and deployments from local modules, public registry, or private registry sources, managing multi-region or multi-environment infrastructure, or troubleshooting Terraform Stacks syntax and structure.

hashicorp/terraform-style-guide

Generate Terraform HCL code following HashiCorp's official style conventions and best practices. Use when writing, reviewing, or generating Terraform configurations.

hashicorp/terraform-test

Comprehensive guide for writing and running Terraform tests. Use when creating test files (.tftest.hcl), writing test scenarios with run blocks, validating infrastructure behavior with assertions, mocking providers and data sources, testing module outputs and resource configurations, or troubleshooting Terraform test syntax and execution.

hashicorp/windows-builder

Build Windows images with Packer using WinRM communicator and PowerShell provisioners. Use when creating Windows AMIs, Azure images, or VMware templates.

相關技能