forked from TrueCloudLab/frostfs-node
[#180] node: Refactor panics in unit test
* Replace panics in unit tests by require.NoError and t.Fatalf Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
91717d4b98
commit
221203beeb
30 changed files with 76 additions and 79 deletions
|
@ -1,7 +1,10 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
)
|
||||
|
@ -11,7 +14,7 @@ const sampling = 1000
|
|||
// NewLogger creates a new logger.
|
||||
//
|
||||
// If debug, development logger is created.
|
||||
func NewLogger(debug bool) *logger.Logger {
|
||||
func NewLogger(t testing.TB, debug bool) *logger.Logger {
|
||||
var l logger.Logger
|
||||
l.Logger = zap.L()
|
||||
|
||||
|
@ -25,10 +28,7 @@ func NewLogger(debug bool) *logger.Logger {
|
|||
cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
|
||||
|
||||
log, err := cfg.Build()
|
||||
if err != nil {
|
||||
panic("could not prepare logger: " + err.Error())
|
||||
}
|
||||
|
||||
require.NoError(t, err, "could not prepare logger")
|
||||
l.Logger = log
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue