Skip to content

Tests for query command outputs #37343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Tests for query command outputs #37343

wants to merge 3 commits into from

Conversation

dsa0x
Copy link
Member

@dsa0x dsa0x commented Jul 18, 2025

This PR introduces some tests for query command outputs. Also, a warning is returned when the config does not have any list resources.

Target Release

1.14.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@dsa0x dsa0x added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Jul 18, 2025
@dsa0x dsa0x force-pushed the sams/query-output-testing branch from e7fd3fb to afb2730 Compare July 18, 2025 11:59
@dsa0x dsa0x marked this pull request as ready for review July 18, 2025 13:45
@dsa0x dsa0x requested review from a team as code owners July 18, 2025 13:45
@dsa0x dsa0x force-pushed the sams/query-output-testing branch from 875323e to d2b4619 Compare July 21, 2025 12:40
t.Fatalf("bad: %d\n\n%s", code, output.Stderr())

// Check that we have query output
if !strings.Contains(actual, ts.expectedOut) {
Copy link
Member

Choose a reason for hiding this comment

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

I expected this test to fail after merging the updates to the line-based output. However, it appears that this line is never executed. I think the if statements are mixed up here.

output = done(t)
actual := output.All()
if len(ts.expectedErr) == 0 {
if code != 0 && len(ts.expectedErr) == 0 {
Copy link
Member

@dbanck dbanck Jul 23, 2025

Choose a reason for hiding this comment

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

Suggested change
if code != 0 && len(ts.expectedErr) == 0 {
if code != 0 {

We already checked this in the line above

diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"No configuration files",
"Query Plan requires a query configuration to be present. Create a Terraform query configuration file (.tfquery.hcl file) and try again.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Query Plan requires a query configuration to be present. Create a Terraform query configuration file (.tfquery.hcl file) and try again.",
"Query requires a query configuration to be present. Create a Terraform query configuration file (.tfquery.hcl file) and try again.",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog-needed Add this to your PR if the change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants