Skip to content

Commit

Permalink
add logger tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adwski committed Jan 26, 2024
1 parent 9970646 commit c16d0ee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/generators/generators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package generators
import (
"encoding/base64"
"errors"
"testing"

"github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/assert"
"testing"
)

func TestID_Get(t *testing.T) {
Expand Down
36 changes: 36 additions & 0 deletions internal/logging/logger_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package logging

import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/zap/zapcore"
)

func TestGetZapLoggerConsole(t *testing.T) {
l := GetZapLoggerConsole()
l.Sugar().Desugar()
}

func TestGetZapLoggerDefaultLevel(t *testing.T) {
l := GetZapLoggerDefaultLevel()
l.Sugar().Desugar()

assert.Equal(t, defaultLogLevel, l.Level())
}

func TestGetZapLoggerWithLevelEmpty(t *testing.T) {
_, err := GetZapLoggerWithLevel("")
assert.ErrorContains(t, err, "log level cannot be empty")
}

func TestGetZapLoggerWithLevelIncorrect(t *testing.T) {
_, err := GetZapLoggerWithLevel("qweqweqw")
assert.ErrorContains(t, err, "cannot parse log level")
}

func TestGetZapLoggerWithLevel(t *testing.T) {
l, err := GetZapLoggerWithLevel("error")
assert.NoError(t, err)
assert.Equal(t, zapcore.ErrorLevel, l.Level())
}

0 comments on commit c16d0ee

Please sign in to comment.