diff --git a/.goreleaser.yaml b/.goreleaser.yaml index d3f598c..89d7ef3 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -35,6 +35,9 @@ changelog: - title: Features regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$' order: 0 + - title: Maintenance + regexp: '^.*?maint(\([[:word:]]+\))??!?:.+$' + order: 1 - title: "Bug fixes" regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$' - title: Others diff --git a/backends/postgres/postgres_backend_test.go b/backends/postgres/postgres_backend_test.go index b169820..5eea8c3 100644 --- a/backends/postgres/postgres_backend_test.go +++ b/backends/postgres/postgres_backend_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "log" "os" "strings" "testing" @@ -324,7 +323,7 @@ func TestBasicJobProcessingWithErrors(t *testing.T) { return }) - nq.SetLogger(testutils.TestLogger{L: log.New(testutils.ChanWriter{Ch: logsChan}, "", 0)}) + nq.SetLogger(testutils.NewTestLogger(logsChan)) err = nq.Start(ctx, queue, h) if err != nil { diff --git a/backends/redis/redis_backend_test.go b/backends/redis/redis_backend_test.go index 0bf0d0e..39c91b5 100644 --- a/backends/redis/redis_backend_test.go +++ b/backends/redis/redis_backend_test.go @@ -266,8 +266,7 @@ func TestJobProcessingWithOptions(t *testing.T) { } defer nq.Shutdown(ctx) - logger := testutils.TestLogger{L: log.New(&testutils.ChanWriter{Ch: logsChan}, "", 0)} - nq.SetLogger(logger) + nq.SetLogger(testutils.NewTestLogger(logsChan)) h := handler.New(func(_ context.Context) (err error) { time.Sleep(50 * time.Millisecond) diff --git a/neoq_test.go b/neoq_test.go index 89d711e..55d834b 100644 --- a/neoq_test.go +++ b/neoq_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "log" "os" "strings" "testing" @@ -206,7 +205,7 @@ func TestSetLogger(t *testing.T) { } defer nq.Shutdown(ctx) - nq.SetLogger(testutils.TestLogger{L: log.New(testutils.ChanWriter{Ch: logsChan}, "", 0)}) + nq.SetLogger(testutils.NewTestLogger(logsChan)) h := handler.New(func(ctx context.Context) (err error) { err = errTrigger diff --git a/testutils/testutils.go b/testutils/testutils.go index e0ff466..b76b5f7 100644 --- a/testutils/testutils.go +++ b/testutils/testutils.go @@ -7,31 +7,38 @@ import ( "strings" ) +// NewTestLogger returns a new TestLogger that logs messages to the given channel +func NewTestLogger(ch chan string) *TestLogger { + return &TestLogger{ + L: log.New(ChanWriter{ch: ch}, "", 0), + } +} + // TestLogger is a utility for logging in tests type TestLogger struct { L *log.Logger } -// Info prints to stdout and signals its done channel +// Info prints to stdout, with args separated by spaces func (h TestLogger) Info(m string, args ...any) { h.L.Println(m, args) } -// Debug prints to stdout and signals its done channel +// Debug prints to stdout, with args separates by spaces func (h TestLogger) Debug(m string, args ...any) { h.L.Println(m, args) } -// Error prints to stdout and signals its done channel +// Error prints to stdout with args separated by spaces func (h TestLogger) Error(m string, args ...any) { h.L.Println(m, args) } type ChanWriter struct { - Ch chan string + ch chan string } func (c ChanWriter) Write(p []byte) (n int, err error) { - c.Ch <- strings.Trim(string(p), "\n") + c.ch <- strings.Trim(string(p), "\n") return len(p), nil }