Skip to content

Commit

Permalink
Merge pull request #344 from bavix/gripmock-check
Browse files Browse the repository at this point in the history
[3.x] gripmock check
  • Loading branch information
rez1dent3 authored Jul 10, 2024
2 parents d76e86c + a681605 commit 07002d0
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 25 deletions.
6 changes: 3 additions & 3 deletions cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ var checkCmd = &cobra.Command{
return err
}

status, err := pingService.PingWithTimeout(ctx, pingTimeout, serviceName)
code, err := pingService.PingWithTimeout(ctx, pingTimeout, serviceName)
if err != nil {
zerolog.Ctx(ctx).Err(err).Msg("unable to connect to server")

return err
}

if status != waiter.Serving {
zerolog.Ctx(ctx).Error().Uint32("code", uint32(status)).Msg("server is not running")
if code != waiter.Serving {
zerolog.Ctx(ctx).Error().Uint32("code", uint32(code)).Msg("server is not running")

return errServerIsNotRunning
}
Expand Down
2 changes: 1 addition & 1 deletion example/ms/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
gripmock --stub=example/ms/stub example/ms/ms.proto &

# wait for generated files to be available and gripmock is up
sleep 2
gripmock check --timeout=30s

go run example/ms/client/*.go
2 changes: 1 addition & 1 deletion example/multi-files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ gripmock --stub=example/multi-files/stub example/multi-files/file1.proto \
example/multi-files/file2.proto &

# wait for generated files to be available and gripmock is up
sleep 2
gripmock check --timeout=30s

go run example/multi-files/client/*.go
2 changes: 1 addition & 1 deletion example/multi-package/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ gripmock --stub=example/multi-package/stub --imports=example/multi-package/ \
example/multi-package/foo.proto example/multi-package/hello.proto &

# wait for generated files to be available and gripmock is up
sleep 2
gripmock check --timeout=30s

go run example/multi-package/client/*.go
2 changes: 1 addition & 1 deletion example/one-of/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
gripmock --stub=example/one-of/stub example/one-of/oneof.proto &

# wait for generated files to be available and gripmock is up
sleep 2
gripmock check --timeout=30s

go run example/one-of/client/*.go
2 changes: 1 addition & 1 deletion example/simple/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
gripmock --stub=example/simple/stub example/simple/simple.proto &

# wait for generated files to be available and gripmock is up
sleep 2
gripmock check --timeout=30s

go run example/simple/client/*.go
2 changes: 1 addition & 1 deletion example/stream/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
gripmock --stub=example/stream/stub example/stream/stream.proto &

# wait for generated files to be available and gripmock is up
sleep 2
gripmock check --timeout=30s

go run example/stream/client/*.go
2 changes: 1 addition & 1 deletion example/stub-subfolders/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
gripmock --stub=example/stub-subfolders/stub example/stub-subfolders/stub-subfolders.proto &

# wait for generated files to be available and gripmock is up
sleep 2
gripmock check --timeout=30s

go run example/stub-subfolders/client/*.go
2 changes: 1 addition & 1 deletion example/well_known_types/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
gripmock --stub=example/well_known_types/stub example/well_known_types/wkt.proto &

# wait for generated files to be available and gripmock is up
sleep 2
gripmock check --timeout=30s

go run example/well_known_types/client/*.go
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.22.2
require (
github.com/bavix/features v1.0.0
github.com/bavix/gripmock-sdk-go v1.0.4
github.com/bavix/gripmock-ui v1.0.0-alpha5
github.com/bavix/gripmock/protogen v0.0.0-20240707160904-f1a1ccbfe8b6
github.com/bavix/gripmock-ui v1.0.0-alpha6
github.com/bavix/gripmock/protogen v0.0.0-20240709053640-e0d876e2e696
github.com/cristalhq/base64 v0.1.2
github.com/goccy/go-yaml v1.11.3
github.com/google/uuid v1.6.0
Expand All @@ -22,7 +22,6 @@ require (
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
golang.org/x/text v0.16.0
google.golang.org/genproto/googleapis/api v0.0.0-20240709173604-40e1e62336c5
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.2
Expand All @@ -47,6 +46,7 @@ require (
golang.org/x/exp v0.0.0-20240707233637-46b078467d37 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240709173604-40e1e62336c5 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ github.com/bavix/features v1.0.0 h1:KyJzP1aKdTWSO7RxwX0Hega9qHUrSdiwdhI+uhAjUg4=
github.com/bavix/features v1.0.0/go.mod h1:OLOA0UEsGMPY0Ofc/4kjajVB/H1zvITPAegB9RkewqM=
github.com/bavix/gripmock-sdk-go v1.0.4 h1:FDBlusqVFoy5Yo49khztYqfVt9+NSEf1mIl1nQWoTr4=
github.com/bavix/gripmock-sdk-go v1.0.4/go.mod h1:/1cmn8VuN6Pc7ttMejqXLYpvf1CJF08ezoEA9lJIZiU=
github.com/bavix/gripmock-ui v1.0.0-alpha5 h1:+2vWLZPeGGrpBSENWXIfyf6bwN+Pou+XucX0XlccLQo=
github.com/bavix/gripmock-ui v1.0.0-alpha5/go.mod h1:XEH4YYEKL+wEDtONntoWm6JxjbVWzl7XtDYztUTBfeA=
github.com/bavix/gripmock/protogen v0.0.0-20240707160904-f1a1ccbfe8b6 h1:VmSRk5/9OK0MVjBS56wvXVGB5Vpc00Ex4KR0MM+qabo=
github.com/bavix/gripmock/protogen v0.0.0-20240707160904-f1a1ccbfe8b6/go.mod h1:ARIfXpB9cyL9jIr7C1yrhwnb3wCSrewPNLdyG4URmJk=
github.com/bavix/gripmock-ui v1.0.0-alpha6 h1:fgDg/R6MLmrpKtR9Rn2a9DEq8qpfjG0OMhRnU72uSR4=
github.com/bavix/gripmock-ui v1.0.0-alpha6/go.mod h1:XEH4YYEKL+wEDtONntoWm6JxjbVWzl7XtDYztUTBfeA=
github.com/bavix/gripmock/protogen v0.0.0-20240709053640-e0d876e2e696 h1:QIOhL5eLnASn6XB4bN9ip/UbxhG/PcEjeHufRsZj30M=
github.com/bavix/gripmock/protogen v0.0.0-20240709053640-e0d876e2e696/go.mod h1:ARIfXpB9cyL9jIr7C1yrhwnb3wCSrewPNLdyG4URmJk=
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
github.com/bufbuild/protocompile v0.14.0 h1:z3DW4IvXE5G/uTOnSQn+qwQQxvhckkTWLS/0No/o7KU=
github.com/bufbuild/protocompile v0.14.0/go.mod h1:N6J1NYzkspJo3ZwyL4Xjvli86XOj1xq4qAasUFxGups=
Expand Down
11 changes: 4 additions & 7 deletions internal/deps/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ import (
"google.golang.org/grpc/credentials/insecure"
)

func (b *Builder) dialOptions(_ bool) []grpc.DialOption {
return []grpc.DialOption{
func (b *Builder) grpcClientConn(_ bool, dsn string) (*grpc.ClientConn, error) {
conn, err := grpc.NewClient(
dsn,
grpc.WithTransportCredentials(insecure.NewCredentials()),
}
}

func (b *Builder) grpcClientConn(tls bool, dsn string) (*grpc.ClientConn, error) {
conn, err := grpc.NewClient(dsn, b.dialOptions(tls)...)
)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 07002d0

Please sign in to comment.