gitea源码

team_repo_test.go 909B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2024 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package organization_test
  4. import (
  5. "testing"
  6. "code.gitea.io/gitea/models/organization"
  7. "code.gitea.io/gitea/models/perm"
  8. "code.gitea.io/gitea/models/repo"
  9. "code.gitea.io/gitea/models/unit"
  10. "code.gitea.io/gitea/models/unittest"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestGetTeamsWithAccessToRepoUnit(t *testing.T) {
  14. assert.NoError(t, unittest.PrepareTestDatabase())
  15. org41 := unittest.AssertExistsAndLoadBean(t, &organization.Organization{ID: 41})
  16. repo61 := unittest.AssertExistsAndLoadBean(t, &repo.Repository{ID: 61})
  17. teams, err := organization.GetTeamsWithAccessToAnyRepoUnit(t.Context(), org41.ID, repo61.ID, perm.AccessModeRead, unit.TypePullRequests)
  18. assert.NoError(t, err)
  19. if assert.Len(t, teams, 2) {
  20. assert.EqualValues(t, 21, teams[0].ID)
  21. assert.EqualValues(t, 22, teams[1].ID)
  22. }
  23. }