build-flow.api/tests/BuildFlow.IM.Tests/Chat/UpdateGroupCommandHandlerTests.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

57 lines
2.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.Shared.Domain.Errors;
using BuildFlow.Shared.Domain.Exceptions;
using FluentAssertions;
using IM.Application.Chat.Commands;
using IM.Application.Chat.Handlers;
using IM.Infrastructure.Persistence;
using Xunit;
namespace BuildFlow.IM.Tests.Chat;
/// <summary>
/// UpdateGroupCommandHandler:群不存在 NotFound;普通成员改群信息 Business;群主改群名成功。
/// </summary>
public class UpdateGroupCommandHandlerTests
{
private static readonly Guid OwnerId = Guid.Parse("22222222-2222-2222-2222-222222222222");
private static readonly Guid MemberId = Guid.Parse("33333333-3333-3333-3333-333333333333");
private const string Name = "group-1";
[Fact]
public async Task Throws_not_found_when_group_missing()
{
await using var db = IMTestDb.Create();
var handler = new UpdateGroupCommandHandler(db);
var act = async () => await handler.Handle(new UpdateGroupCommand(Guid.NewGuid(), OwnerId, "x", null, null), CancellationToken.None);
var ex = await act.Should().ThrowAsync<NotFoundException>();
ex.Which.Code.Should().Be(ErrorCode.NotFound);
}
[Fact]
public async Task Throws_business_when_operator_is_member()
{
await using var db = IMTestDb.Create();
var (_, groupId) = await IMTestDb.SeedGroupAsync(db, Name, OwnerId, MemberId);
var handler = new UpdateGroupCommandHandler(db);
var act = async () => await handler.Handle(new UpdateGroupCommand(groupId, MemberId, "new", null, null), CancellationToken.None);
var ex = await act.Should().ThrowAsync<BusinessException>();
ex.Which.Code.Should().Be(ErrorCode.Business);
}
[Fact]
public async Task Owner_updates_name()
{
await using var db = IMTestDb.Create();
var (_, groupId) = await IMTestDb.SeedGroupAsync(db, Name, OwnerId, MemberId);
var handler = new UpdateGroupCommandHandler(db);
var result = await handler.Handle(new UpdateGroupCommand(groupId, OwnerId, "renamed", null, null), CancellationToken.None);
result.Name.Should().Be("renamed");
var g = await db.Groups.FindAsync(groupId);
g.Should().NotBeNull();
g!.Name.Should().Be("renamed");
}
}