Skip to content

Commit

Permalink
Fix windows test
Browse files Browse the repository at this point in the history
Signed-off-by: Edward McFarlane <[email protected]>
  • Loading branch information
emcfarlane committed Dec 20, 2024
1 parent f94f80d commit c8a29a0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/protoc-gen-connect-go/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io"
"os"
"os/exec"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -180,8 +181,13 @@ func testCmpToTestdata(t *testing.T, content, path string) {
assert.Nil(t, err)
// Strip the copyright header and generated by line.
fileContent := string(b)
fileContent = fileContent[strings.Index(fileContent, "\n\n")+2:]
fileContent = strings.Replace(fileContent, "Code generated by protoc-gen-connect-go.", "Code generated by main.", 1)
if codeGenerateIndex := strings.Index(fileContent, "// Code generated by"); codeGenerateIndex != -1 {
fileContent = fileContent[codeGenerateIndex:]
fileContent = strings.Replace(fileContent, "Code generated by protoc-gen-connect-go.", "Code generated by main.", 1)
}
if runtime.GOOS == "windows" {
fileContent = strings.ReplaceAll(fileContent, "\r\n", "\n")
}
assert.Zero(t, cmp.Diff(content, fileContent))
}

Expand Down

0 comments on commit c8a29a0

Please sign in to comment.