diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-08-16 10:22:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 10:22:25 +0800 |
commit | 86c85c19b625e6ddd99f220a13ee3b5c4cc398e1 (patch) | |
tree | 2545e0c31d5e240b1b168041601c2c24db63bae4 /models/webhook/webhook_test.go | |
parent | e3308a092ad00585607089434b2ec5ec4f07c539 (diff) | |
download | gitea-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 'models/webhook/webhook_test.go')
-rw-r--r-- | models/webhook/webhook_test.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/models/webhook/webhook_test.go b/models/webhook/webhook_test.go index 4bc811586d..1d77ee2a41 100644 --- a/models/webhook/webhook_test.go +++ b/models/webhook/webhook_test.go @@ -31,14 +31,14 @@ func TestIsValidHookContentType(t *testing.T) { func TestWebhook_History(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - webhook := unittest.AssertExistsAndLoadBean(t, &Webhook{ID: 1}).(*Webhook) + webhook := unittest.AssertExistsAndLoadBean(t, &Webhook{ID: 1}) tasks, err := webhook.History(0) assert.NoError(t, err) if assert.Len(t, tasks, 1) { assert.Equal(t, int64(1), tasks[0].ID) } - webhook = unittest.AssertExistsAndLoadBean(t, &Webhook{ID: 2}).(*Webhook) + webhook = unittest.AssertExistsAndLoadBean(t, &Webhook{ID: 2}) tasks, err = webhook.History(0) assert.NoError(t, err) assert.Len(t, tasks, 0) @@ -46,7 +46,7 @@ func TestWebhook_History(t *testing.T) { func TestWebhook_UpdateEvent(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - webhook := unittest.AssertExistsAndLoadBean(t, &Webhook{ID: 1}).(*Webhook) + webhook := unittest.AssertExistsAndLoadBean(t, &Webhook{ID: 1}) hookEvent := &HookEvent{ PushOnly: true, SendEverything: false, @@ -162,7 +162,7 @@ func TestGetWebhooksByOrgID(t *testing.T) { func TestUpdateWebhook(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - hook := unittest.AssertExistsAndLoadBean(t, &Webhook{ID: 2}).(*Webhook) + hook := unittest.AssertExistsAndLoadBean(t, &Webhook{ID: 2}) hook.IsActive = true hook.ContentType = ContentTypeForm unittest.AssertNotExistsBean(t, hook) @@ -220,7 +220,7 @@ func TestCreateHookTask(t *testing.T) { func TestUpdateHookTask(t *testing.T) { assert.NoError(t, unittest.PrepareTestDatabase()) - hook := unittest.AssertExistsAndLoadBean(t, &HookTask{ID: 1}).(*HookTask) + hook := unittest.AssertExistsAndLoadBean(t, &HookTask{ID: 1}) hook.PayloadContent = "new payload content" hook.DeliveredString = "new delivered string" hook.IsDelivered = true |