Skip to content

Commit

Permalink
fix: tweak cli integration test (#1320)
Browse files Browse the repository at this point in the history
Ports an internal change meant to prepare for upgrading jhump/protoreflect ahead of [protobuf editions](https://protobuf.dev/editions/overview/) support.
  • Loading branch information
noahdietz authored Jan 22, 2024
1 parent aaab334 commit 931ab2d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cmd/api-linter/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"path/filepath"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
)

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

func TestBuildErrors(t *testing.T) {
expected := `internal/testdata/build_errors.proto:8:1: expected ';'
internal/testdata/build_errors.proto:13:1: expected ';'`
expected := []string{
"internal/testdata/build_errors.proto:8:1:",
"internal/testdata/build_errors.proto:13:1:",
}
err := runCLI([]string{"internal/testdata/build_errors.proto"})
if err == nil {
t.Fatal("expected build error for build_errors.proto")
}
actual := err.Error()
if expected != actual {
t.Fatalf("expected %q, got %q", expected, actual)
actualLines := strings.Split(strings.TrimSpace(actual), "\n")
for idx, line := range actualLines {
if idx := strings.IndexByte(line, ' '); idx > -1 {
line = line[:idx]
}
actualLines[idx] = line
}
if diff := cmp.Diff(expected, actualLines); diff != "" {
t.Fatalf("unexpected errors: diff (-want +got):\n%s", diff)
}
}

Expand Down

0 comments on commit 931ab2d

Please sign in to comment.