@@ -39,7 +39,27 @@ func TestMain(m *testing.M) {
3939
4040 // setup
4141 hook = New (& Config {UUID : "MY_UUID" })
42- hook .RegisterEvents (HandlePayload , RepoPushEvent , RepoForkEvent , RepoCommitCommentCreatedEvent , RepoCommitStatusCreatedEvent , RepoCommitStatusUpdatedEvent , IssueCreatedEvent , IssueUpdatedEvent , IssueCommentCreatedEvent , PullRequestCreatedEvent , PullRequestUpdatedEvent , PullRequestApprovedEvent , PullRequestApprovalRemovedEvent , PullRequestMergedEvent , PullRequestDeclinedEvent , PullRequestCommentCreatedEvent , PullRequestCommentUpdatedEvent , PullRequestCommentDeletedEvent )
42+ hook .RegisterEvents (
43+ HandlePayload ,
44+ RepoPushEvent ,
45+ RepoForkEvent ,
46+ RepoUpdatedEvent ,
47+ RepoCommitCommentCreatedEvent ,
48+ RepoCommitStatusCreatedEvent ,
49+ RepoCommitStatusUpdatedEvent ,
50+ IssueCreatedEvent ,
51+ IssueUpdatedEvent ,
52+ IssueCommentCreatedEvent ,
53+ PullRequestCreatedEvent ,
54+ PullRequestUpdatedEvent ,
55+ PullRequestApprovedEvent ,
56+ PullRequestUnapprovedEvent ,
57+ PullRequestMergedEvent ,
58+ PullRequestDeclinedEvent ,
59+ PullRequestCommentCreatedEvent ,
60+ PullRequestCommentUpdatedEvent ,
61+ PullRequestCommentDeletedEvent ,
62+ )
4363
4464 go webhooks .Run (hook , "127.0.0.1:" + strconv .Itoa (port ), path )
4565 time .Sleep (time .Millisecond * 500 )
@@ -445,6 +465,142 @@ func TestRepoFork(t *testing.T) {
445465 Equal (t , resp .StatusCode , http .StatusOK )
446466}
447467
468+ func TestRepoUpdated (t * testing.T ) {
469+
470+ payload := `{
471+ "actor": {
472+ "type": "user",
473+ "username": "emmap1",
474+ "display_name": "Emma",
475+ "uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
476+ "links": {
477+ "self": {
478+ "href": "https://api.bitbucket.org/api/2.0/users/emmap1"
479+ },
480+ "html": {
481+ "href": "https://api.bitbucket.org/emmap1"
482+ },
483+ "avatar": {
484+ "href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
485+ }
486+ }
487+ },
488+ "repository": {
489+ "type": "repository",
490+ "links": {
491+ "self": {
492+ "href": "https://api.bitbucket.org/api/2.0/repositories/bitbucket/bitbucket"
493+ },
494+ "html": {
495+ "href": "https://api.bitbucket.org/bitbucket/bitbucket"
496+ },
497+ "avatar": {
498+ "href": "https://api-staging-assetroot.s3.amazonaws.com/c/photos/2014/Aug/01/bitbucket-logo-2629490769-3_avatar.png"
499+ }
500+ },
501+ "uuid": "{673a6070-3421-46c9-9d48-90745f7bfe8e}",
502+ "project": {
503+ "type": "project",
504+ "project": "Untitled project",
505+ "uuid": "{3b7898dc-6891-4225-ae60-24613bb83080}",
506+ "links": {
507+ "html": {
508+ "href": "https://bitbucket.org/account/user/teamawesome/projects/proj"
509+ },
510+ "avatar": {
511+ "href": "https://bitbucket.org/account/user/teamawesome/projects/proj/avatar/32"
512+ }
513+ },
514+ "key": "proj"
515+ },
516+ "full_name": "team_name/repo_name",
517+ "name": "repo_name",
518+ "website": "https://mywebsite.com/",
519+ "owner": {
520+ "type": "user",
521+ "username": "emmap1",
522+ "display_name": "Emma",
523+ "uuid": "{a54f16da-24e9-4d7f-a3a7-b1ba2cd98aa3}",
524+ "links": {
525+ "self": {
526+ "href": "https://api.bitbucket.org/api/2.0/users/emmap1"
527+ },
528+ "html": {
529+ "href": "https://api.bitbucket.org/emmap1"
530+ },
531+ "avatar": {
532+ "href": "https://bitbucket-api-assetroot.s3.amazonaws.com/c/photos/2015/Feb/26/3613917261-0-emmap1-avatar_avatar.png"
533+ }
534+ }
535+ },
536+ "scm": "git",
537+ "is_private": true
538+ },
539+ "changes": {
540+ "name": {
541+ "new": "repository",
542+ "old": "repository_name"
543+ },
544+ "website": {
545+ "new": "http://www.example.com/",
546+ "old": ""
547+ },
548+ "language": {
549+ "new": "java",
550+ "old": ""
551+ },
552+ "links": {
553+ "new": {
554+ "avatar": {
555+ "href": "https://bitbucket.org/teamawesome/repository/avatar/32/"
556+ },
557+ "self": {
558+ "href": "https://api.bitbucket.org/2.0/repositories/teamawesome/repository"
559+ },
560+ "html": {
561+ "href": "https://bitbucket.org/teamawesome/repository"
562+ }
563+ },
564+ "old": {
565+ "avatar": {
566+ "href": "https://bitbucket.org/teamawesome/repository_name/avatar/32/"
567+ },
568+ "self": {
569+ "href": "https://api.bitbucket.org/2.0/repositories/teamawesome/repository_name"
570+ },
571+ "html": {
572+ "href": "https://bitbucket.org/teamawesome/repository_name"
573+ }
574+ }
575+ },
576+ "description": {
577+ "new": "This is a better description.",
578+ "old": "This is a description."
579+ },
580+ "full_name": {
581+ "new": "teamawesome/repository",
582+ "old": "teamawesome/repository_name"
583+ }
584+ }
585+ }
586+ `
587+
588+ req , err := http .NewRequest ("POST" , "http://127.0.0.1:3009/webhooks" , bytes .NewBuffer ([]byte (payload )))
589+ req .Header .Set ("Content-Type" , "application/json" )
590+ req .Header .Set ("X-Hook-UUID" , "MY_UUID" )
591+ req .Header .Set ("X-Event-Key" , "repo:updated" )
592+
593+ Equal (t , err , nil )
594+
595+ client := & http.Client {}
596+ resp , err := client .Do (req )
597+ Equal (t , err , nil )
598+
599+ defer resp .Body .Close ()
600+
601+ Equal (t , resp .StatusCode , http .StatusOK )
602+ }
603+
448604func TestRepoCommitCommentCreated (t * testing.T ) {
449605
450606 payload := `{
0 commit comments