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.

general_test.go 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Copyright 2019 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 webhook
  5. import (
  6. api "code.gitea.io/gitea/modules/structs"
  7. )
  8. func issueTestPayload() *api.IssuePayload {
  9. return &api.IssuePayload{
  10. Index: 2,
  11. Sender: &api.User{
  12. UserName: "user1",
  13. },
  14. Repository: &api.Repository{
  15. HTMLURL: "http://localhost:3000/test/repo",
  16. Name: "repo",
  17. FullName: "test/repo",
  18. },
  19. Issue: &api.Issue{
  20. ID: 2,
  21. Index: 2,
  22. URL: "http://localhost:3000/api/v1/repos/test/repo/issues/2",
  23. Title: "crash",
  24. },
  25. }
  26. }
  27. func issueCommentTestPayload() *api.IssueCommentPayload {
  28. return &api.IssueCommentPayload{
  29. Action: api.HookIssueCommentCreated,
  30. Sender: &api.User{
  31. UserName: "user1",
  32. },
  33. Repository: &api.Repository{
  34. HTMLURL: "http://localhost:3000/test/repo",
  35. Name: "repo",
  36. FullName: "test/repo",
  37. },
  38. Comment: &api.Comment{
  39. HTMLURL: "http://localhost:3000/test/repo/issues/2#issuecomment-4",
  40. IssueURL: "http://localhost:3000/test/repo/issues/2",
  41. Body: "more info needed",
  42. },
  43. Issue: &api.Issue{
  44. ID: 2,
  45. Index: 2,
  46. URL: "http://localhost:3000/api/v1/repos/test/repo/issues/2",
  47. Title: "crash",
  48. Body: "this happened",
  49. },
  50. }
  51. }
  52. func pullRequestCommentTestPayload() *api.IssueCommentPayload {
  53. return &api.IssueCommentPayload{
  54. Action: api.HookIssueCommentCreated,
  55. Sender: &api.User{
  56. UserName: "user1",
  57. },
  58. Repository: &api.Repository{
  59. HTMLURL: "http://localhost:3000/test/repo",
  60. Name: "repo",
  61. FullName: "test/repo",
  62. },
  63. Comment: &api.Comment{
  64. HTMLURL: "http://localhost:3000/test/repo/pulls/2#issuecomment-4",
  65. PRURL: "http://localhost:3000/test/repo/pulls/2",
  66. Body: "changes requested",
  67. },
  68. Issue: &api.Issue{
  69. ID: 2,
  70. Index: 2,
  71. URL: "http://localhost:3000/api/v1/repos/test/repo/issues/2",
  72. Title: "Fix bug",
  73. Body: "fixes bug #2",
  74. },
  75. IsPull: true,
  76. }
  77. }
  78. func pullReleaseTestPayload() *api.ReleasePayload {
  79. return &api.ReleasePayload{
  80. Action: api.HookReleasePublished,
  81. Sender: &api.User{
  82. UserName: "user1",
  83. },
  84. Repository: &api.Repository{
  85. HTMLURL: "http://localhost:3000/test/repo",
  86. Name: "repo",
  87. FullName: "test/repo",
  88. },
  89. Release: &api.Release{
  90. TagName: "v1.0",
  91. Target: "master",
  92. Title: "First stable release",
  93. URL: "http://localhost:3000/api/v1/repos/test/repo/releases/2",
  94. },
  95. }
  96. }
  97. func pullRequestTestPayload() *api.PullRequestPayload {
  98. return &api.PullRequestPayload{
  99. Action: api.HookIssueOpened,
  100. Index: 2,
  101. Sender: &api.User{
  102. UserName: "user1",
  103. },
  104. Repository: &api.Repository{
  105. HTMLURL: "http://localhost:3000/test/repo",
  106. Name: "repo",
  107. FullName: "test/repo",
  108. },
  109. PullRequest: &api.PullRequest{
  110. ID: 2,
  111. Index: 2,
  112. URL: "http://localhost:3000/test/repo/pulls/12",
  113. Title: "Fix bug",
  114. Body: "fixes bug #2",
  115. Mergeable: true,
  116. },
  117. }
  118. }