build-flow.api/tests/BuildFlow.Rag.Tests/RefreshAiModelCatalogQueryHandlerTests.cs
xiangning 7479521546 feat(rag): 实现RAG模块的Hybrid检索和向量索引优化
- 添加HNSW向量索引提升检索性能
- 实现Hybrid检索模式支持向量和关键词双路召回
- 采用RRF算法融合多路召回结果
- 支持ParentChild分块模式的上下文回填
- 优化向量写入采用批量SQL操作提升性能
- 添加RAG PostgreSQL连接字符串配置
- 更新部署脚本增加PGVector集成测试
- 修正表名引用从document_chunks到b_document_chunks
- 重构RagRetrievalService实现完整的检索流程
- 增加重排策略支持关键词和LLM重排
- 修改服务器部署地址配置
2026-08-11 10:59:09 +08:00

36 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BuildFlow.Application.AiModel.DTOs;
using BuildFlow.Application.AiModel.Handlers;
using BuildFlow.Application.AiModel.Queries;
using BuildFlow.Shared.Domain.Errors;
using BuildFlow.Shared.Domain.Exceptions;
using FluentAssertions;
using Xunit;
namespace BuildFlow.Rag.Tests;
/// <summary>
/// 刷新远端模型目录处理器测试。
/// 该 Handler 直接调用真实网络(https://models.dev/api.json),无前置分支、无注入点。
/// 单测仅验证「可达即返回非空目录 / 不可达即抛 BusinessException(ErrorCode.Business)」两种实际行为,
/// 不假设网络环境,不做断言强耦合。
/// </summary>
public class RefreshAiModelCatalogQueryHandlerTests
{
[Fact]
public async Task Handle_EitherReturnsCatalogOrThrowsBusinessOnUnreachable()
{
var handler = new RefreshAiModelCatalogQueryHandler();
try
{
var result = await handler.Handle(new RefreshAiModelCatalogQuery(), CancellationToken.None);
result.Should().NotBeNull();
result.Providers.Should().NotBeNull();
}
catch (BusinessException ex)
{
ex.Code.Should().Be(ErrorCode.Business);
}
}
}