summaryrefslogtreecommitdiff
path: root/internal/logging/logging_test.go
blob: 716781ed8871f076a319bf6276a4251920214070 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package logging

import (
    "bytes"
    "log"
    "testing"
)

func TestPreviewAndLogfAndChatLogger(t *testing.T) {
    var buf bytes.Buffer
    Bind(log.New(&buf, "", 0))
    SetLogPreviewLimit(3)
    if got := PreviewForLog("abcdef"); got != "abc…" {
        t.Fatalf("preview wrong: %q", got)
    }
    Logf("unit ", "hello %s", "x")
    cl := NewChatLogger("p")
    cl.LogStart(true, "m", 0.5, 100, []string{"stop"}, []struct{ Role, Content string }{{"user", "hello"}})
    out := buf.String()
    if out == "" || !bytes.Contains([]byte(out), []byte("start")) {
        t.Fatalf("expected logged content, got %q", out)
    }
}