fix: 明确 Skill Git 访问策略注入构造器

- 标记生产构造器供 Spring 容器稳定选择

- 补充组件实例化回归测试
This commit is contained in:
2026-08-20 11:24:09 +08:00
parent 7d654c3302
commit 7f083a9433
2 changed files with 24 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package tech.easyflow.skill.gitimport;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import tech.easyflow.common.web.exceptions.BusinessException;
import java.io.IOException;
@@ -11,6 +12,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
/**
@@ -30,6 +32,20 @@ public class GitRepositoryAccessPolicyTest {
policy = new GitRepositoryAccessPolicy(properties);
}
/**
* Spring 容器应选择生产构造器完成组件实例化。
*/
@Test
public void springContextUsesProductionConstructor() {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.registerBean(SkillGitImportProperties.class, SkillGitImportProperties::new);
context.register(GitRepositoryAccessPolicy.class);
context.refresh();
assertNotNull(context.getBean(GitRepositoryAccessPolicy.class));
}
}
/**
* 仓库地址允许省略 .git 后缀并移除结尾斜线。
*/