Skip to content

Commit e835242

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

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
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: 17 additions & 13 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"
@@ -26,14 +25,18 @@ func TestQuery(t *testing.T) {
2625
{
2726
name: "basic query",
2827
directory: "basic",
29-
expectedOut: `list.test_instance.example id=test-instance-1 Test Instance 1
30-
list.test_instance.example id=test-instance-2 Test Instance 2`,
28+
expectedOut: `list.test_instance.example id=test-instance-1 Test Instance 1
29+
list.test_instance.example id=test-instance-2 Test Instance 2
30+
31+
`,
3132
},
3233
{
3334
name: "query referencing local variable",
3435
directory: "with-locals",
35-
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+
expectedOut: `list.test_instance.example id=test-instance-1 Test Instance 1
37+
list.test_instance.example id=test-instance-2 Test Instance 2
38+
39+
`,
3740
},
3841
{
3942
name: "config with no query block",
@@ -62,8 +65,8 @@ The configuration does not contain any resources that can be queried.
6265
expectedErr: []string{`
6366
Error: No configuration files
6467
65-
Query Plan requires a query configuration to be present. Create a Terraform
66-
query configuration file (.tfquery.hcl file) and try again.
68+
Query requires a query configuration to be present. Create a Terraform query
69+
configuration file (.tfquery.hcl file) and try again.
6770
`},
6871
},
6972
{
@@ -117,18 +120,19 @@ Blocks of type "resource" are not expected here.
117120
output = done(t)
118121
actual := output.All()
119122
if len(ts.expectedErr) == 0 {
120-
if code != 0 && len(ts.expectedErr) == 0 {
123+
if code != 0 {
121124
t.Fatalf("bad: %d\n\n%s", code, output.Stderr())
125+
}
122126

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-
}
127+
// Check that we have query output
128+
if diff := cmp.Diff(ts.expectedOut, actual); diff != "" {
129+
t.Errorf("expected query output to contain %q, \ngot: %q, \ndiff: %s", ts.expectedOut, actual, diff)
127130
}
131+
128132
} else {
129133
for _, expected := range ts.expectedErr {
130134
if diff := cmp.Diff(expected, actual); diff != "" {
131-
t.Errorf("expected error message to contain '%s', \ngot: %s, diff: %s", expected, actual, diff)
135+
t.Errorf("expected error message to contain '%s', \ngot: %s, \ndiff: %s", expected, actual, diff)
132136
}
133137
}
134138
}

0 commit comments

Comments
 (0)