Skip to content

Commit

Permalink
Refactor log_test.go and add unit tests for Setup function
Browse files Browse the repository at this point in the history
  • Loading branch information
mantzas committed Oct 20, 2024
1 parent 2c82f61 commit 1578b27
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions observability/log/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ import (
"github.com/stretchr/testify/assert"
)

func TestSetup(t *testing.T) {
t.Run("JSON", func(t *testing.T) {
cfg := &Config{
Attributes: []slog.Attr{},
IsJSON: true,
Level: "debug",
}
Setup(cfg)
assert.NotNil(t, slog.Default())
})

t.Run("Text", func(t *testing.T) {
cfg := &Config{
Attributes: []slog.Attr{},
IsJSON: false,
Level: "debug",
}
Setup(cfg)
assert.NotNil(t, slog.Default())
})
}

func TestContext(t *testing.T) {
l := slog.Default()

Expand Down

0 comments on commit 1578b27

Please sign in to comment.