Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: use separate pkg for tests, enforce testing public interface #4

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions handler_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sloggokit
package sloggokit_test

import (
"bytes"
Expand All @@ -12,6 +12,8 @@ import (
"github.com/go-kit/log"
"github.com/go-logfmt/logfmt"
"github.com/stretchr/testify/require"

slgk "github.com/tjhop/slog-gokit"
)

var (
Expand All @@ -21,7 +23,7 @@ var (
func TestNewGoKitHandler(t *testing.T) {
t.Run("nil level", func(t *testing.T) {
var buf bytes.Buffer
h := NewGoKitHandler(log.NewLogfmtLogger(&buf), nil)
h := slgk.NewGoKitHandler(log.NewLogfmtLogger(&buf), nil)

results := func() []map[string]any {
var ms []map[string]any
Expand Down Expand Up @@ -54,7 +56,7 @@ func TestNewGoKitHandler(t *testing.T) {
var buf bytes.Buffer
lvl := &slog.LevelVar{}
lvl.Set(slog.LevelDebug)
h := NewGoKitHandler(log.NewLogfmtLogger(&buf), lvl)
h := slgk.NewGoKitHandler(log.NewLogfmtLogger(&buf), lvl)

results := func() []map[string]any {
var ms []map[string]any
Expand Down Expand Up @@ -88,7 +90,7 @@ func TestNewGoKitHandler(t *testing.T) {
lvl := &slog.LevelVar{}

gklogger := log.NewLogfmtLogger(&buf)
h := NewGoKitHandler(gklogger, lvl)
h := slgk.NewGoKitHandler(gklogger, lvl)
slogger := slog.New(h)

wantedLevelCounts := map[string]int{"info": 1, "debug": 1}
Expand Down
Loading