Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump google.golang.org/grpc to 1.64.0 #113

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
run:
tests: true
deadline: 5m
timeout: 5m

linters-settings:
errcheck:
Expand All @@ -13,16 +13,16 @@ linters-settings:
threshold: 100
misspell:
locale: US
unused:
check-exported: false
unparam:
check-exported: true

linters:
enable-all: true
disable:
- copyloopvar
- deadcode
- depguard
- execinquery
- exhaustivestruct
- exhaustruct
- forbidigo
Expand All @@ -32,10 +32,12 @@ linters:
- golint
- gomnd
- ifshort
- intrange
- interfacer
- ireturn
- lll
- maligned
- mnd
- nolintlint # https://github.com/golangci/golangci-lint/issues/3063
- nonamedreturns
- nosnakecase
Expand All @@ -50,11 +52,14 @@ linters:
- wrapcheck

issues:
max-issues-per-linter: 200
max-same-issues: 50
exclude-use-default: false
exclude-rules:
- linters:
- containedctx
- dupl
- err113
- funlen
- goconst
- goerr113
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ MODULE_NAME = grpcmock

VENDOR_DIR = vendor

GOLANGCI_LINT_VERSION ?= v1.55.2
GOLANGCI_LINT_VERSION ?= v1.58.0

GO ?= go
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)
Expand Down
10 changes: 8 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ func prepInvoke(ctx context.Context, method string, opts ...InvokeOption) (conte

ctx, dialOpts, callOpts := invokeOptions(ctx, opts...)

conn, err := grpc.DialContext(ctx, addr, dialOpts...)
if addr == "" {
addr = "passthrough://"
}

conn, err := grpc.NewClient(addr, dialOpts...)
if err != nil {
return ctx, nil, "", nil, err
}
Expand All @@ -169,7 +173,7 @@ func parseMethod(method string) (string, string, error) {
addr := methodRegex.ReplaceAllString(method, "")

method = strings.Replace(method, addr, "", 1)
method = fmt.Sprintf("/%s", strings.TrimLeft(method, "/"))
method = "/" + strings.TrimLeft(method, "/")

return addr, method, nil
}
Expand All @@ -187,6 +191,8 @@ func invokeOptions(ctx context.Context, opts ...InvokeOption) (context.Context,
ctx = metadata.NewOutgoingContext(ctx, metadata.New(cfg.header))
}

// cfg.dialOpts = append([]grpc.DialOption{withDefaultScheme("passthrough")}, cfg.dialOpts...)

return ctx, cfg.dialOpts, cfg.callOpts
}

Expand Down
9 changes: 4 additions & 5 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package grpcmock_test
import (
"context"
"errors"
"fmt"
"io"
"net"
"testing"
Expand Down Expand Up @@ -67,7 +66,7 @@ func TestInvokeUnary_Unimplemented(t *testing.T) {
defer srv.Stop()

go func() {
_ = srv.Serve(l) // nolint: errcheck
_ = srv.Serve(l) //nolint: errcheck
}()

err := grpcmock.InvokeUnary(context.Background(), "grpctest.ItemService/GetItem", nil, nil,
Expand Down Expand Up @@ -433,7 +432,7 @@ func TestInvokeBidirectionalStream_Success(t *testing.T) {
return err
}

msg.Name = fmt.Sprintf("Modified %s", msg.GetName())
msg.Name = "Modified " + msg.GetName()

if err := srv.SendMsg(msg); err != nil {
return err
Expand Down Expand Up @@ -540,7 +539,7 @@ func TestRecvAll(t *testing.T) {

s.On("RecvMsg", &grpctest.Item{}).Once().
Run(func(args mock.Arguments) {
out := args.Get(0).(*grpctest.Item) // nolint: errcheck
out := args.Get(0).(*grpctest.Item) //nolint: errcheck

proto.Merge(out, i)
}).
Expand Down Expand Up @@ -739,7 +738,7 @@ func TestSendAndRecvAll_Success(t *testing.T) {
mockStream: xmock.MockClientStream(func(s *xmock.ClientStream) {
s.On("RecvMsg", mock.Anything).Once().
Run(func(args mock.Arguments) {
out := args.Get(0).(*grpctest.Item) // nolint: errcheck
out := args.Get(0).(*grpctest.Item) //nolint: errcheck

*out = grpctest.Item{Id: 42, Name: "Modified"}
}).
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
go.nhat.io/aferomock v0.4.0
go.nhat.io/matcher/v2 v2.0.0
go.nhat.io/wait v0.1.0
google.golang.org/grpc v1.63.2
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.1
)

Expand All @@ -27,10 +27,10 @@ require (
github.com/stretchr/objx v0.5.2 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -126,12 +126,12 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand All @@ -150,15 +150,15 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
3 changes: 1 addition & 2 deletions helper.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package grpcmock

import (
"fmt"
"strings"

"google.golang.org/grpc"
)

func methodName(v string) string {
return fmt.Sprintf("/%s", strings.TrimLeft(v, "/"))
return "/" + strings.TrimLeft(v, "/")
}

func serviceSorter(services []*grpc.ServiceDesc) ([]*grpc.ServiceDesc, func(i, j int) bool) {
Expand Down
5 changes: 2 additions & 3 deletions invoker/invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package invoker_test
import (
"context"
"errors"
"fmt"
"io"
"testing"
"time"
Expand Down Expand Up @@ -32,7 +31,7 @@ func TestInvoker_Invoke_Unary_Unimplemented(t *testing.T) {
defer srv.Stop()

go func() {
_ = srv.Serve(l) // nolint: errcheck
_ = srv.Serve(l) //nolint: errcheck
}()

err := invoker.New(getItemMethod(),
Expand Down Expand Up @@ -234,7 +233,7 @@ func TestInvoker_Invoke_BidirectionalStream_Success(t *testing.T) {
return err
}

msg.Name = fmt.Sprintf("Modified %s", msg.GetName())
msg.Name = "Modified " + msg.GetName()

if err := srv.SendMsg(msg); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion matcher/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (m HeaderMatcher) Match(ctx context.Context) error {
}

if !matched {
return fmt.Errorf("header %q with value %q expected, %q received", h, m.Expected(), value) // nolint: goerr113
return fmt.Errorf("header %q with value %q expected, %q received", h, m.Expected(), value) //nolint: goerr113
}
}

Expand Down
4 changes: 2 additions & 2 deletions mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func MockServer(opts ...ServerOption) ServerMocker {
t.Cleanup(func() {
assert.NoError(t, s.ExpectationsWereMet())

_ = s.Close() // nolint: errcheck
_ = s.Close() //nolint: errcheck
})

return s
Expand All @@ -48,7 +48,7 @@ func MockServerWithBufConn(opts ...ServerOption) ServerMockerWithContextDialer {
buf := bufconn.Listen(1024 * 1024)
opts = append(opts, WithListener(buf))

return MockServer(opts...)(t), func(ctx context.Context, s string) (net.Conn, error) {
return MockServer(opts...)(t), func(context.Context, string) (net.Conn, error) {
return buf.Dial()
}
}
Expand Down
2 changes: 1 addition & 1 deletion mock_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func ExampleMockServer() {

// Call the service.
out := &grpctest.Item{}
method := fmt.Sprintf("%s/grpctest.ItemService/GetItem", srv.Address())
method := srv.Address() + "/grpctest.ItemService/GetItem"
err := grpcmock.InvokeUnary(context.Background(),
method, &grpctest.GetItemRequest{Id: 41}, out,
grpcmock.WithInsecure(),
Expand Down
2 changes: 1 addition & 1 deletion planner/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func NewError(ctx context.Context, expected Expectation, req service.Method, in
if in != nil {
in, err := value.Marshal(in)
if err != nil {
in = fmt.Sprintf("could not read request payload: %s", err.Error())
in = "could not read request payload: " + err.Error()
}

actualPayload = in
Expand Down
2 changes: 1 addition & 1 deletion planner/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ func mockCreateItemsStreamer() func(t *testing.T) *streamer.ClientStreamer {
return test.MockCreateItemsStreamer(func(s *xmock.ServerStream) {
s.On("RecvMsg", &grpctest.Item{}).Once().
Run(func(args mock.Arguments) {
item := args.Get(0).(*grpctest.Item) // nolint: errcheck
item := args.Get(0).(*grpctest.Item) //nolint: errcheck

proto.Merge(item, test.DefaultItem())
}).
Expand Down
2 changes: 1 addition & 1 deletion request/client_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (r *ClientStreamRequest) handle(ctx context.Context, in any, out any) error
return status.Error(r.statusCode, r.statusMessage)
}

stream := in.(*streamer.ClientStreamer) // nolint: errcheck
stream := in.(*streamer.ClientStreamer) //nolint: errcheck

resp, err := r.run(ctx, stream)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion request/unary.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewUnaryRequest(locker sync.Locker, svc *service.Method) *UnaryRequest {
fs: afero.NewOsFs(),
},

run: func(ctx context.Context, in any) (any, error) {
run: func(context.Context, any) (any, error) {
return nil, status.Error(codes.Unimplemented, "not implemented")
},
}
Expand Down
2 changes: 1 addition & 1 deletion resources/docs/SERVER.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestServer(t *testing.T) {
)

// Close the server on exit.
defer s.Close(context.Background()) // nolint: errcheck
defer s.Close(context.Background()) //nolint: errcheck

// Call the server and assertions.
}
Expand Down
8 changes: 4 additions & 4 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *Server) WithPlanner(p planner.Planner) *Server {
defer s.mu.Unlock()

if !s.planner.IsEmpty() {
panic(errors.New("could not change planner: planner is not empty")) // nolint: goerr113
panic(errors.New("could not change planner: planner is not empty")) //nolint: goerr113
}

s.planner = p
Expand Down Expand Up @@ -238,7 +238,7 @@ func (s *Server) ExpectationsWereMet() error {
return nil
}

// nolint:goerr113
//nolint:goerr113
return errors.New(sb.String())
}

Expand Down Expand Up @@ -272,7 +272,7 @@ func (s *Server) Serve() {

go func(l net.Listener) {
//goland:noinspection GoUnhandledErrorResult
defer closeListener() // nolint: errcheck
defer closeListener() //nolint: errcheck

must.NotFail(srv.Serve(l))
}(s.listener)
Expand Down Expand Up @@ -470,7 +470,7 @@ func newStreamHandler(
out any
)

// nolint: exhaustive
//nolint: exhaustive
switch svc.MethodType {
case service.TypeServerStream:
in = xreflect.New(svc.Input)
Expand Down
Loading