Skip to content

Commit 931ab2d

Browse files
authored
fix: tweak cli integration test (#1320)
Ports an internal change meant to prepare for upgrading jhump/protoreflect ahead of [protobuf editions](https://protobuf.dev/editions/overview/) support.
1 parent aaab334 commit 931ab2d

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

cmd/api-linter/integration_test.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"path/filepath"
2222
"strings"
2323
"testing"
24+
25+
"github.com/google/go-cmp/cmp"
2426
)
2527

2628
// Each case must be positive when the rule in test
@@ -155,15 +157,24 @@ func TestRules_DisabledByConfig(t *testing.T) {
155157
}
156158

157159
func TestBuildErrors(t *testing.T) {
158-
expected := `internal/testdata/build_errors.proto:8:1: expected ';'
159-
internal/testdata/build_errors.proto:13:1: expected ';'`
160+
expected := []string{
161+
"internal/testdata/build_errors.proto:8:1:",
162+
"internal/testdata/build_errors.proto:13:1:",
163+
}
160164
err := runCLI([]string{"internal/testdata/build_errors.proto"})
161165
if err == nil {
162166
t.Fatal("expected build error for build_errors.proto")
163167
}
164168
actual := err.Error()
165-
if expected != actual {
166-
t.Fatalf("expected %q, got %q", expected, actual)
169+
actualLines := strings.Split(strings.TrimSpace(actual), "\n")
170+
for idx, line := range actualLines {
171+
if idx := strings.IndexByte(line, ' '); idx > -1 {
172+
line = line[:idx]
173+
}
174+
actualLines[idx] = line
175+
}
176+
if diff := cmp.Diff(expected, actualLines); diff != "" {
177+
t.Fatalf("unexpected errors: diff (-want +got):\n%s", diff)
167178
}
168179
}
169180

0 commit comments

Comments
 (0)