Skip to content

Commit

Permalink
Merge pull request #4 from tjhop/test/separate_pkg
Browse files Browse the repository at this point in the history
test: use separate pkg for tests, enforce testing public interface
  • Loading branch information
tjhop authored Jan 2, 2025
2 parents c5558d3 + ec803dd commit 8dfe7b4
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit 8dfe7b4

Please sign in to comment.