diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-06 10:56:27 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-06 10:56:27 +0300 |
| commit | 320de746f7a2985b60c8564a0e65bdf231e840b7 (patch) | |
| tree | e70bcf50813dba411afa2934e774383124bbc99e /internal/logging/logging_test.go | |
| parent | 06247527d5170f329b454b42f59a3e4434ab1f4b (diff) | |
use gofumpt
Diffstat (limited to 'internal/logging/logging_test.go')
| -rw-r--r-- | internal/logging/logging_test.go | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/internal/logging/logging_test.go b/internal/logging/logging_test.go index be8c93f..adeefde 100644 --- a/internal/logging/logging_test.go +++ b/internal/logging/logging_test.go @@ -1,48 +1,48 @@ package logging import ( - "bytes" - "log" - "strings" - "testing" + "bytes" + "log" + "strings" + "testing" ) func TestLogf_WithBindAndPreview(t *testing.T) { - var buf bytes.Buffer - l := log.New(&buf, "", 0) - Bind(l) + var buf bytes.Buffer + l := log.New(&buf, "", 0) + Bind(l) - SetLogPreviewLimit(5) - if got := PreviewForLog("abcdef"); got != "abcde…" { - t.Fatalf("preview truncation failed: %q", got) - } - if got := PreviewForLog("abcd"); got != "abcd" { - t.Fatalf("preview (no trunc) failed: %q", got) - } - SetLogPreviewLimit(0) - if got := PreviewForLog("abcdef"); got != "abcdef" { - t.Fatalf("preview unlimited failed: %q", got) - } + SetLogPreviewLimit(5) + if got := PreviewForLog("abcdef"); got != "abcde…" { + t.Fatalf("preview truncation failed: %q", got) + } + if got := PreviewForLog("abcd"); got != "abcd" { + t.Fatalf("preview (no trunc) failed: %q", got) + } + SetLogPreviewLimit(0) + if got := PreviewForLog("abcdef"); got != "abcdef" { + t.Fatalf("preview unlimited failed: %q", got) + } - Logf("mod ", "hello %s", "world") - out := buf.String() - if !strings.Contains(out, "hello world") || !strings.Contains(out, AnsiBase) || !strings.Contains(out, AnsiReset) { - t.Fatalf("log output missing parts: %q", out) - } + Logf("mod ", "hello %s", "world") + out := buf.String() + if !strings.Contains(out, "hello world") || !strings.Contains(out, AnsiBase) || !strings.Contains(out, AnsiReset) { + t.Fatalf("log output missing parts: %q", out) + } } func TestChatLogger_LogStart(t *testing.T) { - var buf bytes.Buffer - Bind(log.New(&buf, "", 0)) - SetLogPreviewLimit(3) - cl := NewChatLogger("prov") - msgs := []struct{ Role, Content string }{{"user", "abcdef"}, {"assistant", "xyz"}} - cl.LogStart(true, "m", 0.2, 128, []string{"END"}, msgs) - out := buf.String() - if !strings.Contains(out, "stream start model=m") || !strings.Contains(out, "messages=2") { - t.Fatalf("missing header log: %q", out) - } - if !strings.Contains(out, "msg[0] role=user") || !strings.Contains(out, "preview=") { - t.Fatalf("missing message logs: %q", out) - } + var buf bytes.Buffer + Bind(log.New(&buf, "", 0)) + SetLogPreviewLimit(3) + cl := NewChatLogger("prov") + msgs := []struct{ Role, Content string }{{"user", "abcdef"}, {"assistant", "xyz"}} + cl.LogStart(true, "m", 0.2, 128, []string{"END"}, msgs) + out := buf.String() + if !strings.Contains(out, "stream start model=m") || !strings.Contains(out, "messages=2") { + t.Fatalf("missing header log: %q", out) + } + if !strings.Contains(out, "msg[0] role=user") || !strings.Contains(out, "preview=") { + t.Fatalf("missing message logs: %q", out) + } } |
