forgejo/models
Gusted ae57e1b6d7
[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)
2023-06-19 01:03:59 +02:00
..
actions Support changing labels of Actions runner without re-registration (#24806) 2023-06-13 22:28:31 +08:00
activities Use a separate admin page to show global stats, remove actions stat (#25062) 2023-06-03 22:03:41 +08:00
admin Make repo migration cancelable and fix various bugs (#24605) 2023-05-11 08:25:46 +00:00
asymkey Merge setting.InitXXX into one function with options (#24389) 2023-05-04 11:55:35 +08:00
auth Add ability to set multiple redirect URIs in OAuth application UI (#25072) 2023-06-05 15:00:12 +08:00
avatars Avoid warning for system setting when start up (#23054) 2023-02-24 18:23:13 +08:00
db Fix index generation parallelly failure (#25235) 2023-06-15 02:14:43 +02:00
dbfs Merge setting.InitXXX into one function with options (#24389) 2023-05-04 11:55:35 +08:00
fixtures Fix duplicate Reviewed-by trailers (#24796) 2023-06-09 16:34:49 +02:00
forgejo_migrations [DB] Forgejo database migrations 2023-06-19 00:39:26 +02:00
git Fix index generation parallelly failure (#25235) 2023-06-15 02:14:43 +02:00
issues Fix profile render when the README.md size is larger than 1024 bytes (#25131) 2023-06-13 09:02:25 +00:00
migrations [DB] Forgejo database migrations 2023-06-19 00:39:26 +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 Rewrite logger system (#24726) 2023-05-21 22:35:11 +00:00
project Improve GetBoards and getDefaultBoard (#22981) 2023-04-09 22:07:23 +08:00
pull refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
repo [TESTS] add unit test for repository collaboration (#825) 2023-06-19 01:03:59 +02:00
secret Respect original content when creating secrets (#24745) 2023-05-16 14:49:40 +08:00
shared/types Display owner of a runner as a tooltip instead of static text (#24377) 2023-05-12 08:43:27 +00:00
system Avoid warning for system setting when start up (#23054) 2023-02-24 18:23:13 +08:00
unit Rewrite logger system (#24726) 2023-05-21 22:35:11 +00:00
unittest Test query must have "order by" explicitly to avoid unstable results (#24963) 2023-05-29 03:20:57 +00:00
user Show bot label next to username when rendering autor link if the user is a bot (#24943) 2023-05-26 18:58:11 +02:00
webhook New webhook trigger for receiving Pull Request review requests (#24481) 2023-05-24 22:06:27 -04:00
error.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
fixture_generation.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
fixture_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
main_test.go Merge setting.InitXXX into one function with options (#24389) 2023-05-04 11:55:35 +08:00
migrate.go Check primary keys for all tables and drop ForeignReference (#21721) 2022-12-23 19:35:43 +08:00
migrate_test.go Check primary keys for all tables and drop ForeignReference (#21721) 2022-12-23 19:35:43 +08:00
org.go refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
org_team.go Remove org users who belong to no teams (#24247) 2023-04-24 15:52:38 -04:00
org_team_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
org_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
repo.go Implement actions artifacts (#22738) 2023-05-19 21:37:57 +08:00
repo_collaboration.go refactor some functions to support ctx as first parameter (#21878) 2022-12-03 10:48:26 +08:00
repo_collaboration_test.go Rename repo.GetOwner to repo.LoadOwner (#22967) 2023-02-18 20:11:03 +08:00
repo_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
repo_transfer.go Fix unclear IsRepositoryExist logic (#24374) 2023-04-28 14:14:26 -04:00
repo_transfer_test.go Rename almost all Ctx functions (#22071) 2022-12-10 10:46:31 +08:00