1
0
Fork 0
forked from forgejo/forgejo

Refactor AssertExistsAndLoadBean to use generics (#20797)

* Refactor AssertExistsAndLoadBean to use generics

* Fix tests

Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
Lunny Xiao 2022-08-16 10:22:25 +08:00 committed by GitHub
parent e3308a092a
commit 86c85c19b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
159 changed files with 888 additions and 888 deletions

View file

@ -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