|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | +) |
| 6 | + |
| 7 | +var newMergeRequestJson = `{ |
| 8 | + "object_kind": "pipeline", |
| 9 | + "object_attributes": { |
| 10 | + "id": 827393613, |
| 11 | + "iid": 40, |
| 12 | + "ref": "test_webhook_new_mr", |
| 13 | + "tag": false, |
| 14 | + "sha": "9d3bb4e65e705096fda282e3295fdd4b30d9207d", |
| 15 | + "before_sha": "0000000000000000000000000000000000000000", |
| 16 | + "source": "merge_request_event", |
| 17 | + "status": "failed", |
| 18 | + "detailed_status": "failed", |
| 19 | + "stages": [ |
| 20 | + "env", |
| 21 | + "install", |
| 22 | + "digger" |
| 23 | + ], |
| 24 | + "created_at": "2023-04-04 09:41:07 UTC", |
| 25 | + "finished_at": "2023-04-04 09:44:00 UTC", |
| 26 | + "duration": 171, |
| 27 | + "queued_duration": null, |
| 28 | + "variables": [] |
| 29 | + }, |
| 30 | + "merge_request": { |
| 31 | + "id": 215484580, |
| 32 | + "iid": 8, |
| 33 | + "title": "Update main.tf", |
| 34 | + "source_branch": "test_webhook_new_mr", |
| 35 | + "source_project_id": 44723537, |
| 36 | + "target_branch": "main", |
| 37 | + "target_project_id": 44723537, |
| 38 | + "state": "opened", |
| 39 | + "merge_status": "can_be_merged", |
| 40 | + "detailed_merge_status": "mergeable", |
| 41 | + "url": "https://gitlab.com/diggerdev/digger-demo/-/merge_requests/8" |
| 42 | + }, |
| 43 | + "user": { |
| 44 | + "id": 13159253, |
| 45 | + "name": "Alexey Skriptsov", |
| 46 | + "username": "alexey_digger", |
| 47 | + "avatar_url": "https://secure.gravatar.com/avatar/2fbee1042b15f82c532c9f52002cb2d1?s=80&d=identicon", |
| 48 | + "email": "[REDACTED]" |
| 49 | + }, |
| 50 | + "project": { |
| 51 | + "id": 44723537, |
| 52 | + "name": "Digger Demo", |
| 53 | + "description": null, |
| 54 | + "web_url": "https://gitlab.com/diggerdev/digger-demo", |
| 55 | + "avatar_url": null, |
| 56 | + "git_ssh_url": "[email protected]:diggerdev/digger-demo.git", |
| 57 | + "git_http_url": "https://gitlab.com/diggerdev/digger-demo.git", |
| 58 | + "namespace": "diggerdev", |
| 59 | + "visibility_level": 0, |
| 60 | + "path_with_namespace": "diggerdev/digger-demo", |
| 61 | + "default_branch": "main", |
| 62 | + "ci_config_path": "" |
| 63 | + }, |
| 64 | + "commit": { |
| 65 | + "id": "9d3bb4e65e705096fda282e3295fdd4b30d9207d", |
| 66 | + "message": "Update main.tf", |
| 67 | + "title": "Update main.tf", |
| 68 | + "timestamp": "2023-04-04T09:40:59+00:00", |
| 69 | + "url": "https://gitlab.com/diggerdev/digger-demo/-/commit/9d3bb4e65e705096fda282e3295fdd4b30d9207d", |
| 70 | + "author": { |
| 71 | + "name": "Alexey Skriptsov", |
| 72 | + |
| 73 | + } |
| 74 | + }, |
| 75 | + "builds": [ |
| 76 | + { |
| 77 | + "id": 4057216008, |
| 78 | + "stage": "digger", |
| 79 | + "name": "run_digger", |
| 80 | + "status": "skipped", |
| 81 | + "created_at": "2023-04-04 09:41:07 UTC", |
| 82 | + "started_at": null, |
| 83 | + "finished_at": null, |
| 84 | + "duration": null, |
| 85 | + "queued_duration": null, |
| 86 | + "failure_reason": null, |
| 87 | + "when": "on_success", |
| 88 | + "manual": false, |
| 89 | + "allow_failure": false, |
| 90 | + "user": { |
| 91 | + "id": 13159253, |
| 92 | + "name": "Alexey Skriptsov", |
| 93 | + "username": "alexey_digger", |
| 94 | + "avatar_url": "https://secure.gravatar.com/avatar/2fbee1042b15f82c532c9f52002cb2d1?s=80&d=identicon", |
| 95 | + "email": "[REDACTED]" |
| 96 | + }, |
| 97 | + "runner": null, |
| 98 | + "artifacts_file": { |
| 99 | + "filename": null, |
| 100 | + "size": null |
| 101 | + }, |
| 102 | + "environment": null |
| 103 | + }, |
| 104 | + { |
| 105 | + "id": 4057216005, |
| 106 | + "stage": "env", |
| 107 | + "name": "display_env", |
| 108 | + "status": "success", |
| 109 | + "created_at": "2023-04-04 09:41:07 UTC", |
| 110 | + "started_at": "2023-04-04 09:41:08 UTC", |
| 111 | + "finished_at": "2023-04-04 09:41:47 UTC", |
| 112 | + "duration": 38.787836, |
| 113 | + "queued_duration": 0.101601, |
| 114 | + "failure_reason": null, |
| 115 | + "when": "on_success", |
| 116 | + "manual": false, |
| 117 | + "allow_failure": false, |
| 118 | + "user": { |
| 119 | + "id": 13159253, |
| 120 | + "name": "Alexey Skriptsov", |
| 121 | + "username": "alexey_digger", |
| 122 | + "avatar_url": "https://secure.gravatar.com/avatar/2fbee1042b15f82c532c9f52002cb2d1?s=80&d=identicon", |
| 123 | + "email": "[REDACTED]" |
| 124 | + }, |
| 125 | + "runner": { |
| 126 | + "id": 12270807, |
| 127 | + "description": "1-blue.shared.runners-manager.gitlab.com/default", |
| 128 | + "runner_type": "instance_type", |
| 129 | + "active": true, |
| 130 | + "is_shared": true, |
| 131 | + "tags": [ |
| 132 | + "gce", |
| 133 | + "east-c", |
| 134 | + "linux", |
| 135 | + "ruby", |
| 136 | + "mysql", |
| 137 | + "postgres", |
| 138 | + "mongo", |
| 139 | + "git-annex", |
| 140 | + "shared", |
| 141 | + "docker", |
| 142 | + "saas-linux-small-amd64" |
| 143 | + ] |
| 144 | + }, |
| 145 | + "artifacts_file": { |
| 146 | + "filename": null, |
| 147 | + "size": null |
| 148 | + }, |
| 149 | + "environment": null |
| 150 | + }, |
| 151 | + { |
| 152 | + "id": 4057216007, |
| 153 | + "stage": "install", |
| 154 | + "name": "install_digger", |
| 155 | + "status": "failed", |
| 156 | + "created_at": "2023-04-04 09:41:07 UTC", |
| 157 | + "started_at": "2023-04-04 09:41:47 UTC", |
| 158 | + "finished_at": "2023-04-04 09:44:00 UTC", |
| 159 | + "duration": 132.961562, |
| 160 | + "queued_duration": 0.144775, |
| 161 | + "failure_reason": "script_failure", |
| 162 | + "when": "on_success", |
| 163 | + "manual": false, |
| 164 | + "allow_failure": false, |
| 165 | + "user": { |
| 166 | + "id": 13159253, |
| 167 | + "name": "Alexey Skriptsov", |
| 168 | + "username": "alexey_digger", |
| 169 | + "avatar_url": "https://secure.gravatar.com/avatar/2fbee1042b15f82c532c9f52002cb2d1?s=80&d=identicon", |
| 170 | + "email": "[REDACTED]" |
| 171 | + }, |
| 172 | + "runner": { |
| 173 | + "id": 12270807, |
| 174 | + "description": "1-blue.shared.runners-manager.gitlab.com/default", |
| 175 | + "runner_type": "instance_type", |
| 176 | + "active": true, |
| 177 | + "is_shared": true, |
| 178 | + "tags": [ |
| 179 | + "gce", |
| 180 | + "east-c", |
| 181 | + "linux", |
| 182 | + "ruby", |
| 183 | + "mysql", |
| 184 | + "postgres", |
| 185 | + "mongo", |
| 186 | + "git-annex", |
| 187 | + "shared", |
| 188 | + "docker", |
| 189 | + "saas-linux-small-amd64" |
| 190 | + ] |
| 191 | + }, |
| 192 | + "artifacts_file": { |
| 193 | + "filename": null, |
| 194 | + "size": null |
| 195 | + }, |
| 196 | + "environment": null |
| 197 | + } |
| 198 | + ] |
| 199 | +}` |
| 200 | + |
| 201 | +func TestBitbucketPullRequestCommentCreated(t *testing.T) { |
| 202 | + |
| 203 | +} |
0 commit comments