From 9e9811cbb3eade0dd15cd7123f8de7c7347adf23 Mon Sep 17 00:00:00 2001 From: IanShaw027 <131567472+IanShaw027@users.noreply.github.com> Date: Mon, 29 Dec 2025 03:31:03 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E4=BF=AE=E5=A4=8D=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A5=E9=80=82=E9=85=8D=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于简易模式会自动创建3个默认分组(anthropic-default, openai-default, gemini-default), 需要更新测试用例的预期数量: - TestList: 期望5个分组(3个默认 + 2个测试) - TestListActive: 期望4个活跃分组(3个默认 + 1个测试) - TestListActiveByPlatform: 期望2个Anthropic分组(1个默认 + 1个测试) - TestListWithFilters_Platform: 期望2个OpenAI分组(1个默认 + 1个测试) --- .../repository/group_repo_integration_test.go | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/backend/internal/repository/group_repo_integration_test.go b/backend/internal/repository/group_repo_integration_test.go index 33ff6326..42cf2194 100644 --- a/backend/internal/repository/group_repo_integration_test.go +++ b/backend/internal/repository/group_repo_integration_test.go @@ -82,8 +82,9 @@ func (s *GroupRepoSuite) TestList() { groups, page, err := s.repo.List(s.ctx, pagination.PaginationParams{Page: 1, PageSize: 10}) s.Require().NoError(err, "List") - s.Require().Len(groups, 2) - s.Require().Equal(int64(2), page.Total) + // 3 default groups + 2 test groups = 5 total + s.Require().Len(groups, 5) + s.Require().Equal(int64(5), page.Total) } func (s *GroupRepoSuite) TestListWithFilters_Platform() { @@ -92,8 +93,12 @@ func (s *GroupRepoSuite) TestListWithFilters_Platform() { groups, _, err := s.repo.ListWithFilters(s.ctx, pagination.PaginationParams{Page: 1, PageSize: 10}, service.PlatformOpenAI, "", nil) s.Require().NoError(err) - s.Require().Len(groups, 1) - s.Require().Equal(service.PlatformOpenAI, groups[0].Platform) + // 1 default openai group + 1 test openai group = 2 total + s.Require().Len(groups, 2) + // Verify all groups are OpenAI platform + for _, g := range groups { + s.Require().Equal(service.PlatformOpenAI, g.Platform) + } } func (s *GroupRepoSuite) TestListWithFilters_Status() { @@ -151,8 +156,17 @@ func (s *GroupRepoSuite) TestListActive() { groups, err := s.repo.ListActive(s.ctx) s.Require().NoError(err, "ListActive") - s.Require().Len(groups, 1) - s.Require().Equal("active1", groups[0].Name) + // 3 default groups (all active) + 1 test active group = 4 total + s.Require().Len(groups, 4) + // Verify our test group is in the results + var found bool + for _, g := range groups { + if g.Name == "active1" { + found = true + break + } + } + s.Require().True(found, "active1 group should be in results") } func (s *GroupRepoSuite) TestListActiveByPlatform() { @@ -162,8 +176,17 @@ func (s *GroupRepoSuite) TestListActiveByPlatform() { groups, err := s.repo.ListActiveByPlatform(s.ctx, service.PlatformAnthropic) s.Require().NoError(err, "ListActiveByPlatform") - s.Require().Len(groups, 1) - s.Require().Equal("g1", groups[0].Name) + // 1 default anthropic group + 1 test active anthropic group = 2 total + s.Require().Len(groups, 2) + // Verify our test group is in the results + var found bool + for _, g := range groups { + if g.Name == "g1" { + found = true + break + } + } + s.Require().True(found, "g1 group should be in results") } // --- ExistsByName ---