Skip to content

Commit

Permalink
fix coloring test
Browse files Browse the repository at this point in the history
  • Loading branch information
rekby committed Dec 15, 2023
1 parent 734edc1 commit 30e9586
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package log

import (
"testing"
"time"

"github.com/jonboulle/clockwork"
"github.com/stretchr/testify/require"
)

func TestColoring(t *testing.T) {
zeroClock := clockwork.NewFakeClock()
fullDuration := zeroClock.Now().Sub(time.Date(1984, 4, 4, 0, 0, 0, 0, time.Local))
zeroClock.Advance(-fullDuration) // set zero time
for _, tt := range []struct {
l *defaultLogger
msg string
Expand All @@ -16,15 +20,15 @@ func TestColoring(t *testing.T) {
{
l: &defaultLogger{
coloring: true,
clock: clockwork.NewFakeClock(),
clock: zeroClock,
},
msg: "test",
exp: "\u001B[31m1984-04-04 00:00:00.000 \u001B[0m\u001B[101mERROR\u001B[0m\u001B[31m 'test.scope' => message\u001B[0m", //nolint:lll
},
{
l: &defaultLogger{
coloring: false,
clock: clockwork.NewFakeClock(),
clock: zeroClock,
},
msg: "test",
exp: "1984-04-04 00:00:00.000 ERROR 'test.scope' => message",
Expand Down

0 comments on commit 30e9586

Please sign in to comment.