Skip to content

Commit d1ee850

Browse files
committed
Fix tests
1 parent 69ae538 commit d1ee850

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2
8383
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
8484
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
8585
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
86-
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
8786
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
8887
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
8988
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=

internal/entryhuman/entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func Fmt(w io.Writer, ent slog.SinkEntry) string {
6666
}
6767

6868
hpath, hfn := humanPathAndFunc(ent.File, ent.Func)
69-
loc := fmt.Sprintf("<%v:%v> %v", hpath, ent.Line, hfn)
69+
loc := fmt.Sprintf("<%v:%v>\t%v", hpath, ent.Line, hfn)
7070
loc = c(w, color.FgCyan).Sprint(loc)
7171
ents += fmt.Sprintf("%v\t", loc)
7272

internal/entryhuman/entry_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func TestEntry(t *testing.T) {
3232

3333
File: "myfile",
3434
Line: 100,
35-
Func: "ignored",
36-
}, `2000-02-05 04:04:04.000 [DEBUG] <myfile:100> "wowowow\tizi"`)
35+
Func: "mypkg.ignored",
36+
}, `2000-02-05 04:04:04.000 [DEBUG] <mypkg/myfile:100> ignored "wowowow\tizi"`)
3737
})
3838

3939
t.Run("multilineMessage", func(t *testing.T) {
@@ -42,7 +42,7 @@ func TestEntry(t *testing.T) {
4242
test(t, slog.SinkEntry{
4343
Message: "line1\nline2",
4444
Level: slog.LevelInfo,
45-
}, `0001-01-01 00:00:00.000 [INFO] <.:0> ...
45+
}, `0001-01-01 00:00:00.000 [INFO] <.:0> ...
4646
"msg": line1
4747
line2`)
4848
})
@@ -54,7 +54,7 @@ func TestEntry(t *testing.T) {
5454
Message: "msg",
5555
Level: slog.LevelInfo,
5656
Fields: slog.M(slog.F("field", "line1\nline2")),
57-
}, `0001-01-01 00:00:00.000 [INFO] <.:0> msg ...
57+
}, `0001-01-01 00:00:00.000 [INFO] <.:0> msg ...
5858
"field": line1
5959
line2`)
6060
})
@@ -65,7 +65,7 @@ func TestEntry(t *testing.T) {
6565
test(t, slog.SinkEntry{
6666
Level: slog.LevelWarn,
6767
LoggerNames: []string{"named", "meow"},
68-
}, `0001-01-01 00:00:00.000 [WARN] (named.meow) <.:0> ""`)
68+
}, `0001-01-01 00:00:00.000 [WARN] (named.meow) <.:0> ""`)
6969
})
7070

7171
t.Run("trace", func(t *testing.T) {
@@ -77,7 +77,7 @@ func TestEntry(t *testing.T) {
7777
SpanID: trace.SpanID{0, 1, 2, 3, 4, 5, 6, 7},
7878
TraceID: trace.TraceID{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
7979
},
80-
}, `0001-01-01 00:00:00.000 [ERROR] <.:0> "" {"trace": "000102030405060708090a0b0c0d0e0f", "span": "0001020304050607"}`)
80+
}, `0001-01-01 00:00:00.000 [ERROR] <.:0> "" {"trace": "000102030405060708090a0b0c0d0e0f", "span": "0001020304050607"}`)
8181
})
8282

8383
t.Run("color", func(t *testing.T) {
@@ -89,6 +89,6 @@ func TestEntry(t *testing.T) {
8989
slog.F("hey", "hi"),
9090
),
9191
})
92-
assert.Equal(t, "entry", "0001-01-01 00:00:00.000 \x1b[91m[CRITICAL]\x1b[0m\t\x1b[36m<.:0>\x1b[0m\t\"\"\t{\x1b[34m\"hey\"\x1b[0m: \x1b[32m\"hi\"\x1b[0m}", act)
92+
assert.Equal(t, "entry", "\x1b[0m\x1b[0m0001-01-01 00:00:00.000 \x1b[91m[CRITICAL]\x1b[0m\t\x1b[36m<.:0> \x1b[0m\t\"\"\t{\x1b[34m\"hey\"\x1b[0m: \x1b[32m\"hi\"\x1b[0m}", act)
9393
})
9494
}

s_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ func TestStdlib(t *testing.T) {
2323
et, rest, err := entryhuman.StripTimestamp(b.String())
2424
assert.Success(t, "strip timestamp", err)
2525
assert.False(t, "timestamp", et.IsZero())
26-
assert.Equal(t, "entry", " [INFO]\t(stdlib)\t<s_test.go:21>\tstdlib\t{\"hi\": \"we\"}\n", rest)
26+
assert.Equal(t, "entry", " [INFO]\t(stdlib)\t<cdr.dev/slog_test/s_test.go:21>\tTestStdlib\tstdlib\t{\"hi\": \"we\"}\n", rest)
2727
}

sloggers/sloghuman/sloghuman_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ func TestMake(t *testing.T) {
2424
et, rest, err := entryhuman.StripTimestamp(b.String())
2525
assert.Success(t, "strip timestamp", err)
2626
assert.False(t, "timestamp", et.IsZero())
27-
assert.Equal(t, "entry", " [INFO]\t<sloghuman_test.go:21>\t...\t{\"wowow\": \"me\\nyou\"}\n \"msg\": line1\n\n line2\n", rest)
27+
assert.Equal(t, "entry", " [INFO]\t<cdr.dev/slog/sloggers/sloghuman_test/sloghuman_test.go:21>\tTestMake\t...\t{\"wowow\": \"me\\nyou\"}\n \"msg\": line1\n\n line2\n", rest)
2828
}

0 commit comments

Comments
 (0)