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

Commit

Permalink
Fix golang-ci linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
im-kulikov committed Aug 28, 2021
1 parent 0a5977e commit 696eb3b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ func (e *errService) Start(_ context.Context) error {
return nil
}

return testError
return errTest
}

func (e *errService) Stop(context.Context) {
if e.stop {
e.Store(testError)
e.Store(errTest)
}
}

Expand Down Expand Up @@ -71,7 +71,7 @@ func TestDefaultApp(t *testing.T) {
require.NotNil(t, h)
require.NoError(t, err)

require.EqualError(t, h.Run(), testError.Error())
require.EqualError(t, h.Run(), errTest.Error())

cancel()
})
Expand All @@ -93,6 +93,6 @@ func TestDefaultApp(t *testing.T) {

cancel()
require.NoError(t, h.Run())
require.EqualError(t, svc.Load(), testError.Error())
require.EqualError(t, svc.Load(), errTest.Error())
})
}
12 changes: 6 additions & 6 deletions helium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type (
}
)

const testError = Error("test")
const errTest = Error("test")

func (e Error) Error() string {
return string(e)
Expand All @@ -45,7 +45,7 @@ func (e TestError) Error() string {
}

func (h heliumApp) Run(context.Context) error { return nil }
func (h heliumErrApp) Run(context.Context) error { return testError }
func (h heliumErrApp) Run(context.Context) error { return errTest }

func TestHelium(t *testing.T) {
t.Run("create new helium without errors", func(t *testing.T) {
Expand Down Expand Up @@ -160,10 +160,10 @@ func TestHelium(t *testing.T) {
defer monkey.UnpatchAll()

monkey.Patch(logger.NewLogger, func(*logger.Config, *settings.Core) (*zap.Logger, error) {
return nil, testError
return nil, errTest
})
defer monkey.Unpatch(logger.NewLogger)
err := testError
err := errTest
Catch(err)
require.Equal(t, 2, exitCode)
})
Expand All @@ -186,7 +186,7 @@ func TestHelium(t *testing.T) {
})
defer monkey.Unpatch(logger.NewLogger)

err := testError
err := errTest
Catch(err)
require.Equal(t, 1, exitCode)
})
Expand Down Expand Up @@ -218,7 +218,7 @@ func TestHelium(t *testing.T) {

require.Panics(t, func() {
CatchTrace(
testError)
errTest)
})

require.Empty(t, exitCode)
Expand Down
14 changes: 7 additions & 7 deletions web/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/im-kulikov/helium/internal"
)

type testLogger struct {
type logger struct {
*zap.Logger
*bytes.Buffer

Expand All @@ -42,10 +42,10 @@ type testLogResult struct {
N string `json:"name"`
}

func newTestLogger() *testLogger {
func newTestLogger() *logger {
buf := new(bytes.Buffer)

return &testLogger{
return &logger{
Buffer: buf,

Logger: zap.New(zapcore.NewCore(
Expand All @@ -57,20 +57,20 @@ func newTestLogger() *testLogger {
}
}

func (tl *testLogger) Error() string {
func (tl *logger) Error() string {
return tl.Result.E
}

func (tl *testLogger) Cleanup() {
func (tl *logger) Cleanup() {
tl.Buffer.Reset()
tl.Result = new(testLogResult)
}

func (tl *testLogger) Empty() bool {
func (tl *logger) Empty() bool {
return tl.Buffer.String() == ""
}

func (tl *testLogger) Decode() error {
func (tl *logger) Decode() error {
return json.NewDecoder(tl.Buffer).Decode(&tl.Result)
}

Expand Down

0 comments on commit 696eb3b

Please sign in to comment.