Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit baf40ca

Browse files
committed
Add alert status to project hooks
- Add alert status to project hooks
1 parent b5e0812 commit baf40ca

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

projects.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,7 @@ type ProjectHook struct {
12831283
ReleasesEvents bool `json:"releases_events"`
12841284
EnableSSLVerification bool `json:"enable_ssl_verification"`
12851285
CreatedAt *time.Time `json:"created_at"`
1286+
AlertStatus string `json:"alert_status"`
12861287
ResourceAccessTokenEvents bool `json:"resource_access_token_events"`
12871288
CustomWebhookTemplate string `json:"custom_webhook_template"`
12881289
CustomHeaders []*HookCustomHeader `json:"custom_headers"`

projects_test.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,85 @@ func TestProjectModelsOptionalMergeAttribute(t *testing.T) {
14891489
assert.False(t, strings.Contains(string(jsonString), "only_allow_merge_if_all_status_checks_passed"))
14901490
}
14911491

1492+
func TestListProjectHooks(t *testing.T) {
1493+
mux, client := setup(t)
1494+
1495+
mux.HandleFunc("/api/v4/projects/1/hooks", func(w http.ResponseWriter, r *http.Request) {
1496+
testMethod(t, r, http.MethodGet)
1497+
fmt.Fprint(w, `[
1498+
{
1499+
"id": 1,
1500+
"url": "http://example.com/hook",
1501+
"confidential_note_events": true,
1502+
"project_id": 1,
1503+
"push_events": true,
1504+
"push_events_branch_filter": "main",
1505+
"issues_events": true,
1506+
"confidential_issues_events": true,
1507+
"merge_requests_events": true,
1508+
"tag_push_events": true,
1509+
"note_events": true,
1510+
"job_events": true,
1511+
"pipeline_events": true,
1512+
"wiki_page_events": true,
1513+
"deployment_events": true,
1514+
"releases_events": true,
1515+
"enable_ssl_verification": true,
1516+
"alert_status": "executable",
1517+
"created_at": "2024-10-13T13:37:00Z",
1518+
"resource_access_token_events": true,
1519+
"custom_webhook_template": "my custom template",
1520+
"custom_headers": [
1521+
{"key": "Authorization"},
1522+
{"key": "OtherHeader"}
1523+
]
1524+
}
1525+
]`)
1526+
})
1527+
1528+
hooks, _, err := client.Projects.ListProjectHooks(1, nil)
1529+
if err != nil {
1530+
t.Errorf("Projects.ListProjectHooks returned error: %v", err)
1531+
}
1532+
1533+
createdAt := time.Date(2024, 10, 13, 13, 37, 0, 0, time.UTC)
1534+
want := []*ProjectHook{{
1535+
ID: 1,
1536+
URL: "http://example.com/hook",
1537+
ConfidentialNoteEvents: true,
1538+
ProjectID: 1,
1539+
PushEvents: true,
1540+
PushEventsBranchFilter: "main",
1541+
IssuesEvents: true,
1542+
ConfidentialIssuesEvents: true,
1543+
MergeRequestsEvents: true,
1544+
TagPushEvents: true,
1545+
NoteEvents: true,
1546+
JobEvents: true,
1547+
PipelineEvents: true,
1548+
WikiPageEvents: true,
1549+
DeploymentEvents: true,
1550+
ReleasesEvents: true,
1551+
EnableSSLVerification: true,
1552+
CreatedAt: &createdAt,
1553+
AlertStatus: "executable",
1554+
ResourceAccessTokenEvents: true,
1555+
CustomWebhookTemplate: "my custom template",
1556+
CustomHeaders: []*HookCustomHeader{
1557+
{
1558+
Key: "Authorization",
1559+
},
1560+
{
1561+
Key: "OtherHeader",
1562+
},
1563+
},
1564+
}}
1565+
1566+
if !reflect.DeepEqual(hooks, want) {
1567+
t.Errorf("Projects.ListProjectHooks returned \ngot:\n%v\nwant:\n%v", Stringify(hooks), Stringify(want))
1568+
}
1569+
}
1570+
14921571
// Test that the "CustomWebhookTemplate" serializes properly
14931572
func TestProjectAddWebhook_CustomTemplateStuff(t *testing.T) {
14941573
mux, client := setup(t)

0 commit comments

Comments
 (0)