(t *testing.T)
| 561 | } |
| 562 | |
| 563 | func 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 | |
| 593 | func TestHandler_LoadSession_V1Fallback(t *testing.T) { |
| 594 | // Store does NOT implement SessionStoreV2 — should fall back to v1 |
nothing calls this directly
no test coverage detected