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

Function TestHandler_SaveSession_V1Fallback

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

Source from the content-addressed store, hash-verified

561}
562
563func TestHandler_SaveSession_V1Fallback(t *testing.T) {
564 // Store does NOT implement SessionStoreV2 — should fall back to v1
565 logger := zap.NewNop()
566 store := &mockSessionStore{}
567
568 history := []models.Message{
569 {Role: "user", Content: "hello"},
570 }
571 store.On("SaveSession", "test-v1", history).Return(nil)
572
573 handler := &Handler{
574 sessionManager: store,
575 logger: logger,
576 }
577
578 // Even with session_data present, v1 store should use messages field
579 resp, err := handler.SaveSession(context.Background(), &pb.SaveSessionRequest{
580 Name: "test-v1",
581 Messages: []*pb.ChatMessage{{Role: "user", Content: "hello"}},
582 SessionData: &pb.SessionDataV2{
583 Version: 2,
584 ChatHistory: []*pb.ChatMessage{{Role: "user", Content: "hello"}},
585 AgentHistory: []*pb.ChatMessage{{Role: "user", Content: "agent"}},
586 },
587 })
588 assert.NoError(t, err)
589 assert.True(t, resp.Success)
590 store.AssertCalled(t, "SaveSession", "test-v1", history)
591}
592
593func TestHandler_LoadSession_V1Fallback(t *testing.T) {
594 // Store does NOT implement SessionStoreV2 — should fall back to v1

Callers

nothing calls this directly

Calls 1

SaveSessionMethod · 0.95

Tested by

no test coverage detected