MCPcopy Create free account
hub / github.com/diillson/chatcli / TestHandler_LoadSession_V2

Function TestHandler_LoadSession_V2

server/handler_test.go:523–561  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

521}
522
523func TestHandler_LoadSession_V2(t *testing.T) {
524 logger := zap.NewNop()
525 store := &mockSessionStoreV2{}
526
527 sd := &models.SessionData{
528 Version: 2,
529 ChatHistory: []models.Message{
530 {Role: "user", Content: "hello"},
531 {Role: "assistant", Content: "hi"},
532 },
533 AgentHistory: []models.Message{
534 {Role: "user", Content: "agent task"},
535 },
536 CoderHistory: []models.Message{
537 {Role: "user", Content: "coder task"},
538 },
539 }
540
541 store.On("LoadSessionV2", "test-v2").Return(sd, nil)
542
543 handler := &Handler{
544 sessionManager: store,
545 logger: logger,
546 }
547
548 resp, err := handler.LoadSession(context.Background(), &pb.LoadSessionRequest{Name: "test-v2"})
549 assert.NoError(t, err)
550
551 // V1 compat: messages field should contain chat history
552 assert.Len(t, resp.Messages, 2)
553 assert.Equal(t, "user", resp.Messages[0].Role)
554
555 // V2: session_data should contain all scoped histories
556 assert.NotNil(t, resp.SessionData)
557 assert.Equal(t, int32(2), resp.SessionData.Version)
558 assert.Len(t, resp.SessionData.ChatHistory, 2)
559 assert.Len(t, resp.SessionData.AgentHistory, 1)
560 assert.Len(t, resp.SessionData.CoderHistory, 1)
561}
562
563func TestHandler_SaveSession_V1Fallback(t *testing.T) {
564 // Store does NOT implement SessionStoreV2 — should fall back to v1

Callers

nothing calls this directly

Calls 3

LoadSessionMethod · 0.95
EqualMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected