@@ -1489,6 +1489,85 @@ func TestProjectModelsOptionalMergeAttribute(t *testing.T) {
1489
1489
assert .False (t , strings .Contains (string (jsonString ), "only_allow_merge_if_all_status_checks_passed" ))
1490
1490
}
1491
1491
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 \n got:\n %v\n want:\n %v" , Stringify (hooks ), Stringify (want ))
1568
+ }
1569
+ }
1570
+
1492
1571
// Test that the "CustomWebhookTemplate" serializes properly
1493
1572
func TestProjectAddWebhook_CustomTemplateStuff (t * testing.T ) {
1494
1573
mux , client := setup (t )
0 commit comments