Skip to content

Add terraform-plugin-testing documentation for query mode and query checks #1451

Merged
stephybun merged 4 commits intof/plugin-testing-1-14-0from
f/plugin-testing-query-checks
Dec 10, 2025
Merged

Add terraform-plugin-testing documentation for query mode and query checks #1451
stephybun merged 4 commits intof/plugin-testing-1-14-0from
f/plugin-testing-query-checks

Conversation

@stephybun
Copy link
Copy Markdown
Contributor

What

This PR adds documentation for the newly introduced query testing mode as well as the accompanying query checks

What was added:

  • New section specific to query-checks containing
  • New TestSteps subsection for query mode

What changed:

  • TestSteps page was updated to include mentions and references to the new query mode

Why

Terraform introduced a new language construct which users will likely want to know how to test.

Screenshots


Merge Checklist

If items do not apply to your changes, add (N/A) and mark them as complete.

Pull Request

  • Description links to related pull requests or issues, if any.

Content

  • You added redirects to content/terraform-docs-common/redirects.jsonc for moved, renamed, or deleted pages across all affected versions. Refer to Redirects for examples and guidance.
  • Links to related content where appropriate (e.g., CLI, language, API endpoints, permissions, etc.).
  • Pages with related content are updated and link to this content when appropriate.
  • Sidebar navigation files have been updated for added, deleted, reordered, or renamed pages.
  • New pages have metadata (page name and description) at the top.
  • New images are 2048 px wide. They have HashiCorp standard annotation color (#F92672) and format (rectangle with rounded corners), blurred sensitive details (e.g. credentials, usernames, user icons), and descriptive alt text in the markdown for accessibility.
  • New code blocks have the correct syntax and line breaks to eliminate horizontal scroll bars.
  • UI elements (button names, page names, etc.) are bolded.
  • The Vercel website preview successfully deployed.

Reviews

  • I or someone else reviewed the content for technical accuracy.
  • I or someone else reviewed the content for typos, punctuation, spelling, and grammar.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 4, 2025

Vercel Previews Deployed

Name Status Preview Updated (UTC)
Dev Portal ✅ Ready (Inspect) Visit Preview Wed Dec 10 08:15:41 UTC 2025
Unified Docs API ✅ Ready (Inspect) Visit Preview Wed Dec 10 08:11:21 UTC 2025

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 4, 2025

Broken Link Checker

No broken links found! 🎉

Copy link
Copy Markdown
Contributor

@SBGoods SBGoods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a couple of suggestions, but none of it is blocking. Otherwise, LGTM!

Comment thread content/terraform-plugin-testing/v1.14.x/data/plugin-testing-nav-data.json Outdated
@@ -0,0 +1,95 @@
---
page_title: 'Plugin Development - Acceptance Testing: Query Checks'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
page_title: 'Plugin Development - Acceptance Testing: Query Checks'
page_title: 'Plugin Development - Acceptance Testing: Custom Query Checks'

`,
Query: true,
QueryResultChecks: []querycheck.QueryResultCheck{
querycheck.ExpectResultLengthExact("test_resource.test", 3),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I noticed during initial try this function does not exist, assume this refers to https://github.com/hashicorp/terraform-plugin-testing/blob/main/querycheck/expect_result_length_exact.go#L34

Suggested change
querycheck.ExpectResultLengthExact("test_resource.test", 3),
querycheck.ExpectLength("test_resource.test", 3),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks @akinross!

Comment on lines +322 to +331
[]querycheck.KnownValueCheck{,
{
tfjsonpath.New("attr_3"),
knownvalue.StringExact("foobar"),
},
{
tfjsonpath.New("attr_4"),
knownvalue.StringExact("baz"),
},
},
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice a comma added that should not be there in line 322, and perhaps from example point of view it is better readable in format below

Suggested change
[]querycheck.KnownValueCheck{,
{
tfjsonpath.New("attr_3"),
knownvalue.StringExact("foobar"),
},
{
tfjsonpath.New("attr_4"),
knownvalue.StringExact("baz"),
},
},
[]querycheck.KnownValueCheck{
querycheck.KnownValueCheck{
Path: tfjsonpath.New("attr_3"),
KnownValue: knownvalue.StringExact("foobar"),
},
querycheck.KnownValueCheck{
Path: tfjsonpath.New("attr_4"),
KnownValue: knownvalue.StringExact("baz"),
},
},

@stephybun stephybun merged commit 2dc4d60 into f/plugin-testing-1-14-0 Dec 10, 2025
10 checks passed
@stephybun stephybun deleted the f/plugin-testing-query-checks branch December 10, 2025 08:44
stephybun added a commit that referenced this pull request Dec 10, 2025
### What
This PR contains a copy of the existing v1.13.x
`terraform-plugin-testing` docs in preparation for adding documentation
on query mode acceptance testing in v1.14.x

⚠️ Should only be merged after #1451 has been merged into this branch ⚠️

### Why
To make it easier to see the diff of what was actually added or changed
by the addition of the query testing mode docs

### Screenshots
<!-- Optional. Show additions to the sidebar or new formatting. -->

----------

### Merge Checklist
_If items do not apply to your changes, add (N/A) and mark them as
complete._

#### Pull Request
- [ ] Description links to related pull requests or issues, if any.

#### Content
- [ ] You added redirects to
`content/terraform-docs-common/redirects.jsonc` for moved, renamed, or
deleted pages **across all affected versions**. Refer to
[Redirects](https://github.com/hashicorp/web-unified-docs/blob/main/docs/content-guide/redirects.md#example-redirects)
for examples and guidance.
- [ ] Links to related content where appropriate (e.g., CLI, language,
API endpoints, permissions, etc.).
- [ ] Pages with related content are updated and link to this content
when appropriate.
- [ ] Sidebar navigation files have been updated for added, deleted,
reordered, or renamed pages.
- [ ] New pages have metadata (page name and description) at the top.
- [ ] New images are 2048 px wide. They have HashiCorp standard
annotation color (#F92672) and format (rectangle with rounded corners),
blurred sensitive details (e.g. credentials, usernames, user icons), and
descriptive alt text in the markdown for accessibility.
- [ ] New code blocks have the correct syntax and line breaks to
eliminate horizontal scroll bars.
- [ ] UI elements (button names, page names, etc.) are bolded.
- [ ] The Vercel website preview successfully deployed.

#### Reviews
- [ ] I or someone else reviewed the content for technical accuracy.
- [ ] I or someone else reviewed the content for typos, punctuation,
spelling, and grammar.
hashibot-web added a commit that referenced this pull request Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants