mirror of
https://gitea.com/gitea/tea.git
synced 2026-04-26 02:03:30 +02:00
Fix webhook
This commit is contained in:
@@ -84,10 +84,10 @@ func TestWebhookDetails(t *testing.T) {
|
||||
"url": "https://example.com/webhook",
|
||||
"content_type": "json",
|
||||
"http_method": "post",
|
||||
"branch_filter": "main,develop",
|
||||
"secret": "secret-value",
|
||||
"authorization_header": "Bearer token123",
|
||||
},
|
||||
BranchFilter: "main,develop",
|
||||
AuthorizationHeader: "Bearer token123",
|
||||
Events: []string{"push", "pull_request", "issues"},
|
||||
Active: true,
|
||||
Created: now.Add(-24 * time.Hour),
|
||||
@@ -240,14 +240,12 @@ func TestWebhookConfigHandling(t *testing.T) {
|
||||
config: map[string]string{
|
||||
"url": "https://example.com/webhook",
|
||||
"secret": "my-secret",
|
||||
"authorization_header": "Bearer token",
|
||||
"content_type": "json",
|
||||
"http_method": "post",
|
||||
"branch_filter": "main",
|
||||
},
|
||||
expectedURL: "https://example.com/webhook",
|
||||
hasSecret: true,
|
||||
hasAuthHeader: true,
|
||||
hasAuthHeader: false,
|
||||
},
|
||||
{
|
||||
name: "Config with minimal fields",
|
||||
@@ -344,10 +342,10 @@ func TestWebhookDetailsFormatting(t *testing.T) {
|
||||
"url": "https://example.com/webhook",
|
||||
"content_type": "json",
|
||||
"http_method": "post",
|
||||
"branch_filter": "main,develop",
|
||||
"secret": "secret-value",
|
||||
"authorization_header": "Bearer token123",
|
||||
},
|
||||
BranchFilter: "main,develop",
|
||||
AuthorizationHeader: "Bearer token123",
|
||||
Events: []string{"push", "pull_request", "issues"},
|
||||
Active: true,
|
||||
Created: now.Add(-24 * time.Hour),
|
||||
@@ -379,8 +377,8 @@ func TestWebhookDetailsFormatting(t *testing.T) {
|
||||
assert.Equal(t, "https://example.com/webhook", hook.Config["url"])
|
||||
assert.Equal(t, "json", hook.Config["content_type"])
|
||||
assert.Equal(t, "post", hook.Config["http_method"])
|
||||
assert.Equal(t, "main,develop", hook.Config["branch_filter"])
|
||||
assert.Equal(t, "main,develop", hook.BranchFilter)
|
||||
assert.Contains(t, hook.Config, "secret")
|
||||
assert.Contains(t, hook.Config, "authorization_header")
|
||||
assert.Equal(t, "Bearer token123", hook.AuthorizationHeader)
|
||||
assert.Equal(t, []string{"push", "pull_request", "issues"}, hook.Events)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user