summaryrefslogtreecommitdiff
path: root/internal/logging/logging_test.go
blob: 31603f011547848abc7504785a6ce59e5fa53548 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)
	}
}