test: restore green solution baseline
This commit is contained in:
parent
6c9cde1e23
commit
09ced1cd32
@ -4,7 +4,6 @@ using BuildFlow.Infrastructure.AI;
|
|||||||
using BuildFlow.Infrastructure.Persistence;
|
using BuildFlow.Infrastructure.Persistence;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace BuildFlow.Rag.Tests;
|
namespace BuildFlow.Rag.Tests;
|
||||||
@ -22,14 +21,16 @@ public class AiModelRuntimeConfigResolverTests
|
|||||||
services.AddDbContext<RagDbContext>(options =>
|
services.AddDbContext<RagDbContext>(options =>
|
||||||
options.UseInMemoryDatabase(dbName));
|
options.UseInMemoryDatabase(dbName));
|
||||||
services.AddScoped<AiModelRuntimeConfigResolver>();
|
services.AddScoped<AiModelRuntimeConfigResolver>();
|
||||||
services.AddSingleton(Options.Create(new AiOptions
|
services.AddOptions<AiOptions>()
|
||||||
{
|
.Configure(options =>
|
||||||
BaseUrl = "http://localhost:1234/v1",
|
{
|
||||||
ApiKey = "lm-studio",
|
options.BaseUrl = "http://localhost:1234/v1";
|
||||||
ChatModel = "fallback-chat",
|
options.ApiKey = "lm-studio";
|
||||||
EmbeddingModel = "fallback-embedding",
|
options.ChatModel = "fallback-chat";
|
||||||
DefaultInstructions = "你是 BuildFlow AI 助手。没有知识库上下文时按普通对话直接回答。",
|
options.EmbeddingModel = "fallback-embedding";
|
||||||
}));
|
options.DefaultInstructions =
|
||||||
|
"你是 BuildFlow AI 助手。没有知识库上下文时按普通对话直接回答。";
|
||||||
|
});
|
||||||
|
|
||||||
await using var provider = services.BuildServiceProvider();
|
await using var provider = services.BuildServiceProvider();
|
||||||
await using (var scope = provider.CreateAsyncScope())
|
await using (var scope = provider.CreateAsyncScope())
|
||||||
@ -72,14 +73,15 @@ public class AiModelRuntimeConfigResolverTests
|
|||||||
services.AddDbContext<RagDbContext>(options =>
|
services.AddDbContext<RagDbContext>(options =>
|
||||||
options.UseInMemoryDatabase(dbName));
|
options.UseInMemoryDatabase(dbName));
|
||||||
services.AddScoped<AiModelRuntimeConfigResolver>();
|
services.AddScoped<AiModelRuntimeConfigResolver>();
|
||||||
services.AddSingleton(Options.Create(new AiOptions
|
services.AddOptions<AiOptions>()
|
||||||
{
|
.Configure(options =>
|
||||||
BaseUrl = "https://fallback.example/v1",
|
{
|
||||||
ApiKey = "fallback-key",
|
options.BaseUrl = "https://fallback.example/v1";
|
||||||
ChatModel = "fallback-chat",
|
options.ApiKey = "fallback-key";
|
||||||
EmbeddingModel = "fallback-embedding",
|
options.ChatModel = "fallback-chat";
|
||||||
DefaultInstructions = "fallback instructions",
|
options.EmbeddingModel = "fallback-embedding";
|
||||||
}));
|
options.DefaultInstructions = "fallback instructions";
|
||||||
|
});
|
||||||
|
|
||||||
await using var provider = services.BuildServiceProvider();
|
await using var provider = services.BuildServiceProvider();
|
||||||
await using (var scope = provider.CreateAsyncScope())
|
await using (var scope = provider.CreateAsyncScope())
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using BuildFlow.Shared.Domain.Common;
|
using BuildFlow.Shared.Domain.Common;
|
||||||
|
using BuildFlow.Shared.Domain.Errors;
|
||||||
using BuildFlow.Shared.Domain.Exceptions;
|
using BuildFlow.Shared.Domain.Exceptions;
|
||||||
using FluentAssertions;
|
using FluentAssertions;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
@ -99,9 +100,11 @@ public class ScriptExecutionServiceTests
|
|||||||
|
|
||||||
var act = () => svc.ExecuteByIdAsync(script.Id, "{}", CancellationToken.None);
|
var act = () => svc.ExecuteByIdAsync(script.Id, "{}", CancellationToken.None);
|
||||||
|
|
||||||
(await act.Should().ThrowAsync<BusinessException>())
|
var exception = (await act.Should().ThrowAsync<BusinessException>())
|
||||||
.WithMessage("*禁用*")
|
.WithMessage("*禁用 API*")
|
||||||
.Which.Message.Should().Contain("File");
|
.Which;
|
||||||
|
exception.Code.Should().Be(ErrorCode.Business);
|
||||||
|
exception.Message.Should().Contain("System.IO");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── §13 #4: SANDBOX — Reflection 被拦截 ────────────────────────────────
|
// ── §13 #4: SANDBOX — Reflection 被拦截 ────────────────────────────────
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user