aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_repo_git_hook_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-08-16 10:22:25 +0800
committerGitHub <noreply@github.com>2022-08-16 10:22:25 +0800
commit86c85c19b625e6ddd99f220a13ee3b5c4cc398e1 (patch)
tree2545e0c31d5e240b1b168041601c2c24db63bae4 /integrations/api_repo_git_hook_test.go
parente3308a092ad00585607089434b2ec5ec4f07c539 (diff)
downloadgitea-86c85c19b625e6ddd99f220a13ee3b5c4cc398e1.tar.gz
gitea-86c85c19b625e6ddd99f220a13ee3b5c4cc398e1.zip
Refactor AssertExistsAndLoadBean to use generics (#20797)
* Refactor AssertExistsAndLoadBean to use generics * Fix tests Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'integrations/api_repo_git_hook_test.go')
-rw-r--r--integrations/api_repo_git_hook_test.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/integrations/api_repo_git_hook_test.go b/integrations/api_repo_git_hook_test.go
index a31b27c456..b90d66c175 100644
--- a/integrations/api_repo_git_hook_test.go
+++ b/integrations/api_repo_git_hook_test.go
@@ -25,8 +25,8 @@ echo Hello, World!
func TestAPIListGitHooks(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 37}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 37})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
// user1 is an admin user
session := loginUser(t, "user1")
@@ -51,8 +51,8 @@ func TestAPIListGitHooks(t *testing.T) {
func TestAPIListGitHooksNoHooks(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
// user1 is an admin user
session := loginUser(t, "user1")
@@ -72,8 +72,8 @@ func TestAPIListGitHooksNoHooks(t *testing.T) {
func TestAPIListGitHooksNoAccess(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
session := loginUser(t, owner.Name)
token := getTokenForLoggedInUser(t, session)
@@ -85,8 +85,8 @@ func TestAPIListGitHooksNoAccess(t *testing.T) {
func TestAPIGetGitHook(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 37}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 37})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
// user1 is an admin user
session := loginUser(t, "user1")
@@ -103,8 +103,8 @@ func TestAPIGetGitHook(t *testing.T) {
func TestAPIGetGitHookNoAccess(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
session := loginUser(t, owner.Name)
token := getTokenForLoggedInUser(t, session)
@@ -116,8 +116,8 @@ func TestAPIGetGitHookNoAccess(t *testing.T) {
func TestAPIEditGitHook(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
// user1 is an admin user
session := loginUser(t, "user1")
@@ -146,8 +146,8 @@ func TestAPIEditGitHook(t *testing.T) {
func TestAPIEditGitHookNoAccess(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
session := loginUser(t, owner.Name)
token := getTokenForLoggedInUser(t, session)
@@ -162,8 +162,8 @@ func TestAPIEditGitHookNoAccess(t *testing.T) {
func TestAPIDeleteGitHook(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 37}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 37})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
// user1 is an admin user
session := loginUser(t, "user1")
@@ -185,8 +185,8 @@ func TestAPIDeleteGitHook(t *testing.T) {
func TestAPIDeleteGitHookNoAccess(t *testing.T) {
defer prepareTestEnv(t)()
- repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}).(*repo_model.Repository)
- owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID}).(*user_model.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
session := loginUser(t, owner.Name)
token := getTokenForLoggedInUser(t, session)