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 824B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package repo
  5. import (
  6. "net/http"
  7. "testing"
  8. "code.gitea.io/gitea/models"
  9. "code.gitea.io/gitea/modules/context"
  10. "code.gitea.io/gitea/modules/test"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestTestHook(t *testing.T) {
  14. models.PrepareTestEnv(t)
  15. ctx := test.MockContext(t, "user2/repo1/wiki/_pages")
  16. ctx.SetParams(":id", "1")
  17. test.LoadRepo(t, ctx, 1)
  18. test.LoadRepoCommit(t, ctx)
  19. test.LoadUser(t, ctx, 2)
  20. TestHook(&context.APIContext{Context: ctx, Org: nil})
  21. assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status())
  22. models.AssertExistsAndLoadBean(t, &models.HookTask{
  23. RepoID: 1,
  24. HookID: 1,
  25. }, models.Cond("is_delivered=?", false))
  26. }