You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hook_test.go 755B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package repo
  4. import (
  5. "net/http"
  6. "testing"
  7. "code.gitea.io/gitea/models/unittest"
  8. "code.gitea.io/gitea/models/webhook"
  9. "code.gitea.io/gitea/modules/contexttest"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestTestHook(t *testing.T) {
  13. unittest.PrepareTestEnv(t)
  14. ctx, _ := contexttest.MockAPIContext(t, "user2/repo1/wiki/_pages")
  15. ctx.SetParams(":id", "1")
  16. contexttest.LoadRepo(t, ctx, 1)
  17. contexttest.LoadRepoCommit(t, ctx)
  18. contexttest.LoadUser(t, ctx, 2)
  19. TestHook(ctx)
  20. assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status())
  21. unittest.AssertExistsAndLoadBean(t, &webhook.HookTask{
  22. HookID: 1,
  23. }, unittest.Cond("is_delivered=?", false))
  24. }