fix: harden file download flow

This commit is contained in:
liumangmang
2026-04-30 10:30:26 +08:00
parent 3555d19b26
commit aef59e354a
24 changed files with 2316 additions and 2443 deletions
@@ -21,7 +21,11 @@ class AiWorkflowServiceTest {
void shouldResolveDeepSeekProviderByDefault() {
final AiWorkflowService service = new AiWorkflowService(
buildOutputFileService(),
new SettingsService(buildOutputFileService(), new SvnPresetService()),
new SettingsService(
buildOutputFileService(),
new SettingsPersistenceService(),
new SvnPresetService()
),
new AiInputValidator()
);
@@ -35,7 +39,11 @@ class AiWorkflowServiceTest {
@Test
void shouldResolveOpenAiCompatibleModelsAndUrl() {
final OutputFileService outputFileService = buildOutputFileService();
final SettingsService settingsService = new SettingsService(outputFileService, new SvnPresetService());
final SettingsService settingsService = new SettingsService(
outputFileService,
new SettingsPersistenceService(),
new SvnPresetService()
);
settingsService.updateSettings(
null,
SettingsService.PROVIDER_OPENAI_COMPATIBLE,
@@ -44,6 +52,8 @@ class AiWorkflowServiceTest {
"deepseek-v4-flash",
"deepseek-v4-pro",
null,
null,
null,
null
);
final AiWorkflowService service = new AiWorkflowService(outputFileService, settingsService, new AiInputValidator());
@@ -75,7 +85,11 @@ class AiWorkflowServiceTest {
@Test
void shouldParseCompatibleStreamWhenOnlyContentIsReturned() throws Exception {
final OutputFileService outputFileService = buildOutputFileService();
final SettingsService settingsService = new SettingsService(outputFileService, new SvnPresetService());
final SettingsService settingsService = new SettingsService(
outputFileService,
new SettingsPersistenceService(),
new SvnPresetService()
);
settingsService.updateSettings(
null,
SettingsService.PROVIDER_OPENAI_COMPATIBLE,
@@ -84,6 +98,8 @@ class AiWorkflowServiceTest {
"deepseek-v4-flash",
"deepseek-v4-pro",
null,
null,
null,
null
);
final AiWorkflowService service = new AiWorkflowService(outputFileService, settingsService, new AiInputValidator());
@@ -127,7 +143,7 @@ class AiWorkflowServiceTest {
private final String openaiApiKey;
private StubSettingsService(OutputFileService outputFileService, String openaiBaseUrl, String openaiApiKey) {
super(outputFileService, new SvnPresetService());
super(outputFileService, new SettingsPersistenceService(), new SvnPresetService());
this.openaiBaseUrl = openaiBaseUrl;
this.openaiApiKey = openaiApiKey;
}