Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit test for repository collaboration #25640

Merged
merged 5 commits into from
Jul 3, 2023

Commits on Jul 3, 2023

  1. [TESTS] add unit test for repository collaboration (go-gitea#825)

    - Add a few extra test cases and test functions for the collaboration
    model to get everything covered by tests (except for error handling, as
    we cannot suddenly mock errors from the database).
    
    ```
    -> % go tool cover -func=coverage.out | grep "code.gitea.io/gitea/models/repo/collaboration.go"
    ```
    
    Before:
    ```
    code.gitea.io/gitea/models/repo/collaboration.go:28:                            init                                            100.0%
    code.gitea.io/gitea/models/repo/collaboration.go:39:                            GetCollaborators                                61.5%
    code.gitea.io/gitea/models/repo/collaboration.go:65:                            CountCollaborators                              0.0%
    code.gitea.io/gitea/models/repo/collaboration.go:70:                            GetCollaboration                                0.0%
    code.gitea.io/gitea/models/repo/collaboration.go:83:                            IsCollaborator                                  100.0%
    code.gitea.io/gitea/models/repo/collaboration.go:87:                            getCollaborations                               42.9%
    code.gitea.io/gitea/models/repo/collaboration.go:102:                           ChangeCollaborationAccessMode                   77.8%
    code.gitea.io/gitea/models/repo/collaboration.go:141:                           IsOwnerMemberCollaborator                       0.0%
    ```
    
    After:
    ```
    code.gitea.io/gitea/models/repo/collaboration.go:28:                            init                                            100.0%
    code.gitea.io/gitea/models/repo/collaboration.go:39:                            GetCollaborators                                61.5%
    code.gitea.io/gitea/models/repo/collaboration.go:65:                            CountCollaborators                              100.0%
    code.gitea.io/gitea/models/repo/collaboration.go:70:                            GetCollaboration                                100.0%
    code.gitea.io/gitea/models/repo/collaboration.go:83:                            IsCollaborator                                  100.0%
    code.gitea.io/gitea/models/repo/collaboration.go:87:                            getCollaborations                               100.0%
    code.gitea.io/gitea/models/repo/collaboration.go:102:                           ChangeCollaborationAccessMode                   83.3%
    code.gitea.io/gitea/models/repo/collaboration.go:141:                           IsOwnerMemberCollaborator                       87.5%
    ```
    
    Co-authored-by: Gusted <postmaster@gusted.xyz>
    Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/825
    (cherry picked from commit 9de2b618a495d4b3954fae29d6ec9d6437157557)
    (cherry picked from commit e3a6ca67e455b63b26d1e5f93557da9f3ad59312)
    (cherry picked from commit ae57e1b6d7dd38283c19f7731baf625b3d6513ba)
    (cherry picked from commit 5e37ea4)
    Gusted authored and earl-warren committed Jul 3, 2023
    Configuration menu
    Copy the full SHA
    968045b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5f73549 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    abd5c78 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4230563 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    28fa9c1 View commit details
    Browse the repository at this point in the history