forgejo/models
Gusted ef9494ddef
[TESTS] add unit test for repository collaboration (#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 9de2b618a4)
(cherry picked from commit e3a6ca67e4)
(cherry picked from commit ae57e1b6d7)
(cherry picked from commit 5e37ea475d)
2023-07-03 07:56:55 +02:00
..
actions Fix content holes in Actions task logs file (#25560) 2023-06-28 19:07:29 +02:00
activities Use a separate admin page to show global stats, remove actions stat (#25062) 2023-06-03 22:03:41 +08:00
admin
asymkey
auth Add ability to set multiple redirect URIs in OAuth application UI (#25072) 2023-06-05 15:00:12 +08:00
avatars
db Split lfs size from repository size (#22900) 2023-06-28 22:41:02 +00:00
dbfs Fix content holes in Actions task logs file (#25560) 2023-06-28 19:07:29 +02:00
fixtures Fix bug of branches API with tests (#25578) 2023-07-01 10:52:52 +08:00
forgejo_migrations [DB] Forgejo database migrations 2023-07-03 07:56:55 +02:00
git Make FindBranches have stable result (#25631) 2023-07-03 04:11:32 +00:00
issues Improve loadprojects for issue list (#25468) 2023-06-24 15:31:28 +00:00
migrations [DB] Forgejo database migrations 2023-07-03 07:56:55 +02:00
organization Use RepositoryList instead of []*Repository (#25074) 2023-06-05 15:25:47 +08:00
packages Hide limited users if viewed by anonymous ghost (#25214) 2023-06-13 11:21:11 +08:00
perm
project
pull
repo [TESTS] add unit test for repository collaboration (#825) 2023-07-03 07:56:55 +02:00
secret Support configuration variables on Gitea Actions (#24724) 2023-06-20 22:54:15 +00:00
shared/types
system
unit
unittest Refactor path & config system (#25330) 2023-06-21 13:50:26 +08:00
user Sync branches into databases (#22743) 2023-06-29 10:03:20 +00:00
webhook New webhook trigger for receiving Pull Request review requests (#24481) 2023-05-24 22:06:27 -04:00
error.go Sync branches into databases (#22743) 2023-06-29 10:03:20 +00:00
fixture_generation.go
fixture_test.go
main_test.go
migrate.go
migrate_test.go
org.go
org_team.go
org_team_test.go
org_test.go
repo.go Sync branches into databases (#22743) 2023-06-29 10:03:20 +00:00
repo_collaboration.go
repo_collaboration_test.go
repo_test.go
repo_transfer.go
repo_transfer_test.go