Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

1.0 KB
Raw Blame
package usage

import (
	"fmt"
	"testing"
	"time"
)

// A request's row on the Usage page names where the request archive keeps
// it, as its line in the log does, packed away and read back too (#447);
// the Claude message id that follows it is untouched.
func TestRowKeepsArchive(t *testing.T) {
	c := &rowChunk{}
	now := time.Now()
	for i := range 80 {
		r := Row{Record: Record{Time: now.Add(time.Duration(i) * time.Second), Agent: "claude", Model: "m", Input: i, Archive: fmt.Sprintf("2026-10-02/1010%02d-00000000000000aa", i)}}
		c.add(r, fmt.Sprint("msg", i), int64(i), false)
	}
	for _, chunk := range []*rowChunk{c, c.pack().unpack()} {
		if chunk == nil || len(chunk.Rows) != 80 {
			t.Fatal("not read back")
		}
		for i := range chunk.Rows {
			if r := chunk.row(i); r.Archive != fmt.Sprintf("2026-10-02/1010%02d-00000000000000aa", i) || r.Input != i {
				t.Fatalf("row %d: archive %q", i, r.Archive)
			}
			if msg := chunk.Strings[chunk.text(&chunk.Rows[i], rowMsg)]; msg != fmt.Sprint("msg", i) {
				t.Fatalf("row %d: message %q", i, msg)
			}
		}
	}
}