Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from im-kulikov/typos
Browse files Browse the repository at this point in the history
Typos
  • Loading branch information
im-kulikov authored Nov 27, 2019
2 parents 4cab550 + 71000a9 commit 3a71cfb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ type SNMPListener struct {
}

var MyModule = module.Module{
{Constructor: NewSNMPServer}
{Constructor: NewSNMPServer},
}

func NewSNMPServer(v *viper.Viper, l *zap.Logger) (web.ServerResult, error) {
Expand Down Expand Up @@ -428,7 +428,7 @@ type gRPCResult struct {
}

var MyModule = module.Module{
{Constructor: NewDefaultGRPCServer}
{Constructor: NewDefaultGRPCServer},
}

// NewDefaultGRPCServer returns gRPCResult that would be used
Expand Down
2 changes: 1 addition & 1 deletion logger/std.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (s stdLogger) Print(v ...interface{}) {
s.Info(v...)
}

// Printf uses fmt.Sprintf to log a templated message.
// Printf uses fmt.Sprintf to log a formatted message.
func (s stdLogger) Printf(format string, v ...interface{}) {
s.Infof(format, v...)
}
Expand Down
2 changes: 1 addition & 1 deletion web/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestGRPCService(t *testing.T) {
require.EqualError(t, (&gRPC{server: grpc.NewServer()}).Start(), "listen: unknown network ")
})

t.Run("shoud ignore ErrServerStopped", func(t *testing.T) {
t.Run("should ignore ErrServerStopped", func(t *testing.T) {
lis, err := net.Listen("tcp", "127.0.0.1:0")
require.NoError(t, err)
require.NoError(t, lis.Close())
Expand Down
4 changes: 2 additions & 2 deletions web/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ func newDefaultGRPCServer(p grpcParams) (ServerResult, error) {
}

// NewAPIServer creates api server by http.Handler from DI container
func NewAPIServer(v *viper.Viper, l *zap.Logger, h http.Handler) (ServerResult, error) {
return NewHTTPServer(v, "api", h, l)
func NewAPIServer(p APIParams) (ServerResult, error) {
return NewHTTPServer(p.Config, "api", p.Handler, p.Logger)
}

// NewHTTPServer creates http-server that will be embedded into multi-server
Expand Down
18 changes: 11 additions & 7 deletions web/servers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func TestServers(t *testing.T) {
})
require.NoError(t, err)

serv, ok := res.Server.(*gRPC)
serve, ok := res.Server.(*gRPC)
require.True(t, ok)
require.True(t, serv.skipErrors)
require.Equal(t, serv.address, ":0")
require.Equal(t, serv.network, "test")
require.True(t, serve.skipErrors)
require.Equal(t, serve.address, ":0")
require.Equal(t, serve.network, "test")
})
})

Expand Down Expand Up @@ -183,22 +183,26 @@ func TestServers(t *testing.T) {

t.Run("check api server", func(t *testing.T) {
t.Run("without config", func(t *testing.T) {
serve, err := NewAPIServer(v, l, nil)
serve, err := NewAPIServer(APIParams{Config: v, Logger: l})
require.NoError(t, err)
require.Nil(t, serve.Server)
})

t.Run("without handler", func(t *testing.T) {
v.SetDefault("api.address", ":8090")
serve, err := NewAPIServer(v, l, nil)
serve, err := NewAPIServer(APIParams{Config: v, Logger: l})
require.NoError(t, err)
require.Nil(t, serve.Server)
})

t.Run("should be ok", func(t *testing.T) {
assert := require.New(t)
v.SetDefault("api.address", ":8090")
serve, err := NewAPIServer(v, l, testHTTPHandler(assert))
serve, err := NewAPIServer(APIParams{
Config: v,
Logger: l,
Handler: testHTTPHandler(assert),
})
assert.NoError(err)
assert.NotNil(serve.Server)
assert.IsType(&httpService{}, serve.Server)
Expand Down

0 comments on commit 3a71cfb

Please sign in to comment.