Skip to content

Commit c755114

Browse files
committed
Handle Windows
1 parent d83b7ee commit c755114

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

codegen/example/example_client_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package example
33
import (
44
"bytes"
55
"path/filepath"
6+
"runtime"
7+
"strings"
68
"testing"
79

810
"github.com/stretchr/testify/require"
@@ -36,6 +38,9 @@ func TestExampleCLIFiles(t *testing.T) {
3638
require.NoError(t, s.Write(&buf))
3739
}
3840
code := codegen.FormatTestCode(t, "package foo\n"+buf.String())
41+
if runtime.GOOS == "windows" {
42+
code = strings.ReplaceAll(code, "\r\n", "\n")
43+
}
3944
golden := filepath.Join("testdata", "client-"+c.Name+".golden")
4045
compareOrUpdateGolden(t, code, golden)
4146
})

grpc/codegen/proto_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestProtoFiles(t *testing.T) {
4747
if runtime.GOOS == "windows" {
4848
code = strings.ReplaceAll(code, "\r\n", "\n")
4949
}
50-
assert.Equal(t, code, c.Code)
50+
assert.Equal(t, c.Code, code)
5151
fpath := codegen.CreateTempFile(t, code)
5252
assert.NoError(t, protoc(fpath, nil), "error occurred when compiling proto file %q", fpath)
5353
})

0 commit comments

Comments
 (0)