Skip to content

Question: expected results of models.GetRepositoryAccesses()? #10068

Closed
@guillep2k

Description

@guillep2k
  • Gitea version (or commit ref): 04cbdf5 (current master)

While working on #9787, I need to rewrite models.GetRepositoryAccesses(). This function is only used by ListMyRepos() as a complement of GetUserRepositories(). ListMyRepos() works the API function:

// swagger:operation GET /user/repos user userCurrentListRepos

GetRepositoryAccesses() is supposed to return all the repositories that the user has access to but does not own. The problem is that the unit test goes like:

func TestUser_GetRepositoryAccesses(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
user1 := AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
accesses, err := user1.GetRepositoryAccesses()
assert.NoError(t, err)
assert.Len(t, accesses, 0)

With the current data, this function should fail because user1 is a site administrator, so it's got access to all repositories. The test asserts that the function returns zero results.

My question is: is the unit test/fixture set wrong, or is it that the function is expected to ignore the is_admin flag to return a shorter list?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions