Skip to content

Commit bc8b6c9

Browse files
committed
address pr review
1 parent 75baded commit bc8b6c9

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

internal/backend/local/backend_plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (b *Local) opPlan(
4848
diags = diags.Append(tfdiags.Sourceless(
4949
tfdiags.Error,
5050
"No configuration files",
51-
"Query Plan requires a query configuration to be present. Create a Terraform query configuration file (.tfquery.hcl file) and try again.",
51+
"Query requires a query configuration to be present. Create a Terraform query configuration file (.tfquery.hcl file) and try again.",
5252
))
5353
op.ReportResult(runningOp, diags)
5454
return

internal/command/query_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package command
55

66
import (
77
"path"
8-
"strings"
98
"testing"
109

1110
"github.com/google/go-cmp/cmp"
@@ -27,13 +26,15 @@ func TestQuery(t *testing.T) {
2726
name: "basic query",
2827
directory: "basic",
2928
expectedOut: `list.test_instance.example id=test-instance-1 Test Instance 1
30-
list.test_instance.example id=test-instance-2 Test Instance 2`,
29+
list.test_instance.example id=test-instance-2 Test Instance 2
30+
`,
3131
},
3232
{
3333
name: "query referencing local variable",
3434
directory: "with-locals",
3535
expectedOut: `list.test_instance.example id=test-instance-1 Test Instance 1
36-
list.test_instance.example id=test-instance-2 Test Instance 2`,
36+
list.test_instance.example id=test-instance-2 Test Instance 2
37+
`,
3738
},
3839
{
3940
name: "config with no query block",
@@ -62,8 +63,8 @@ The configuration does not contain any resources that can be queried.
6263
expectedErr: []string{`
6364
Error: No configuration files
6465
65-
Query Plan requires a query configuration to be present. Create a Terraform
66-
query configuration file (.tfquery.hcl file) and try again.
66+
Query requires a query configuration to be present. Create a Terraform query
67+
configuration file (.tfquery.hcl file) and try again.
6768
`},
6869
},
6970
{
@@ -117,18 +118,19 @@ Blocks of type "resource" are not expected here.
117118
output = done(t)
118119
actual := output.All()
119120
if len(ts.expectedErr) == 0 {
120-
if code != 0 && len(ts.expectedErr) == 0 {
121+
if code != 0 {
121122
t.Fatalf("bad: %d\n\n%s", code, output.Stderr())
123+
}
122124

123-
// Check that we have query output
124-
if !strings.Contains(actual, ts.expectedOut) {
125-
t.Errorf("expected query output to contain '%s', got: %s", ts.expectedOut, actual)
126-
}
125+
// Check that we have query output
126+
if diff := cmp.Diff(ts.expectedOut, actual); diff != "" {
127+
t.Errorf("expected query output to contain %q, \ngot: %q, \ndiff: %s", ts.expectedOut, actual, diff)
127128
}
129+
128130
} else {
129131
for _, expected := range ts.expectedErr {
130132
if diff := cmp.Diff(expected, actual); diff != "" {
131-
t.Errorf("expected error message to contain '%s', \ngot: %s, diff: %s", expected, actual, diff)
133+
t.Errorf("expected error message to contain '%s', \ngot: %s, \ndiff: %s", expected, actual, diff)
132134
}
133135
}
134136
}

0 commit comments

Comments
 (0)