@@ -21,18 +21,18 @@ func TestCheckValidPayload(t *testing.T) {
2121 payloadEvent types.PullRequestEvent
2222 }{
2323 {
24- name : "missing project" ,
24+ name : "missing toRef. project" ,
2525 payloadEvent : types.PullRequestEvent {
2626 PullRequest : bbv1.PullRequest {
2727 ToRef : bbv1.PullRequestRef {
2828 Repository : bbv1.Repository {},
2929 },
3030 },
3131 },
32- wantErrString : "bitbucket project is nil" ,
32+ wantErrString : "bitbucket toRef project is nil" ,
3333 },
3434 {
35- name : "empty project key" ,
35+ name : "empty toRef. project. key" ,
3636 payloadEvent : types.PullRequestEvent {
3737 PullRequest : bbv1.PullRequest {
3838 ToRef : bbv1.PullRequestRef {
@@ -42,10 +42,10 @@ func TestCheckValidPayload(t *testing.T) {
4242 },
4343 },
4444 },
45- wantErrString : "bitbucket project key is empty" ,
45+ wantErrString : "bitbucket toRef project key is empty" ,
4646 },
4747 {
48- name : "empty repository name " ,
48+ name : "empty toRef.repositoryName " ,
4949 payloadEvent : types.PullRequestEvent {
5050 PullRequest : bbv1.PullRequest {
5151 ToRef : bbv1.PullRequestRef {
@@ -60,7 +60,7 @@ func TestCheckValidPayload(t *testing.T) {
6060 wantErrString : "bitbucket toRef repository name is empty" ,
6161 },
6262 {
63- name : "missing latest commit " ,
63+ name : "missing toRef.latestCommit " ,
6464 payloadEvent : types.PullRequestEvent {
6565 PullRequest : bbv1.PullRequest {
6666 FromRef : bbv1.PullRequestRef {},
@@ -75,6 +75,102 @@ func TestCheckValidPayload(t *testing.T) {
7575 },
7676 },
7777 },
78+ wantErrString : "bitbucket toRef latest commit is empty" ,
79+ },
80+ {
81+ name : "missing fromRef.project" ,
82+ payloadEvent : types.PullRequestEvent {
83+ PullRequest : bbv1.PullRequest {
84+ ToRef : bbv1.PullRequestRef {
85+ Repository : bbv1.Repository {
86+ Name : "repo" ,
87+ Project : & bbv1.Project {
88+ Key : "PROJ" ,
89+ Name : "repo" ,
90+ },
91+ },
92+ LatestCommit : "abcd" ,
93+ },
94+ FromRef : bbv1.PullRequestRef {
95+ Repository : bbv1.Repository {},
96+ },
97+ },
98+ },
99+ wantErrString : "bitbucket fromRef project is nil" ,
100+ },
101+ {
102+ name : "empty fromRef.projectKey" ,
103+ payloadEvent : types.PullRequestEvent {
104+ PullRequest : bbv1.PullRequest {
105+ ToRef : bbv1.PullRequestRef {
106+ Repository : bbv1.Repository {
107+ Name : "repo" ,
108+ Project : & bbv1.Project {
109+ Key : "PROJ" ,
110+ Name : "repo" ,
111+ },
112+ },
113+ LatestCommit : "abcd" ,
114+ },
115+ FromRef : bbv1.PullRequestRef {
116+ Repository : bbv1.Repository {
117+ Project : & bbv1.Project {},
118+ },
119+ },
120+ },
121+ },
122+ wantErrString : "bitbucket fromRef project key is empty" ,
123+ },
124+ {
125+ name : "empty fromRef.repositoryName" ,
126+ payloadEvent : types.PullRequestEvent {
127+ PullRequest : bbv1.PullRequest {
128+ ToRef : bbv1.PullRequestRef {
129+ Repository : bbv1.Repository {
130+ Name : "repo" ,
131+ Project : & bbv1.Project {
132+ Key : "PROJ" ,
133+ Name : "repo" ,
134+ },
135+ },
136+ LatestCommit : "abcd" ,
137+ },
138+ FromRef : bbv1.PullRequestRef {
139+ Repository : bbv1.Repository {
140+ Project : & bbv1.Project {
141+ Key : "PROJ" ,
142+ },
143+ },
144+ },
145+ },
146+ },
147+ wantErrString : "bitbucket fromRef repository name is empty" ,
148+ },
149+ {
150+ name : "missing fromRef.latestCommit" ,
151+ payloadEvent : types.PullRequestEvent {
152+ PullRequest : bbv1.PullRequest {
153+ ToRef : bbv1.PullRequestRef {
154+ Repository : bbv1.Repository {
155+ Name : "repo" ,
156+ Project : & bbv1.Project {
157+ Key : "PROJ" ,
158+ Name : "repo" ,
159+ },
160+ },
161+ LatestCommit : "abcd" ,
162+ },
163+ FromRef : bbv1.PullRequestRef {
164+ Repository : bbv1.Repository {
165+ Name : "repo" ,
166+ Project : & bbv1.Project {
167+ Key : "PROJ" ,
168+ Name : "repo" ,
169+ },
170+ },
171+ },
172+ },
173+ },
78174 wantErrString : "bitbucket fromRef latest commit is empty" ,
79175 },
80176 {
@@ -89,8 +185,16 @@ func TestCheckValidPayload(t *testing.T) {
89185 Name : "repo" ,
90186 },
91187 },
188+ LatestCommit : "abcd" ,
92189 },
93190 FromRef : bbv1.PullRequestRef {
191+ Repository : bbv1.Repository {
192+ Name : "repo" ,
193+ Project : & bbv1.Project {
194+ Key : "PROJ" ,
195+ Name : "repo" ,
196+ },
197+ },
94198 LatestCommit : "abcd" ,
95199 },
96200 },
@@ -109,8 +213,16 @@ func TestCheckValidPayload(t *testing.T) {
109213 Name : "repo" ,
110214 },
111215 },
216+ LatestCommit : "abcd" ,
112217 },
113218 FromRef : bbv1.PullRequestRef {
219+ Repository : bbv1.Repository {
220+ Name : "repo" ,
221+ Project : & bbv1.Project {
222+ Key : "PROJ" ,
223+ Name : "repo" ,
224+ },
225+ },
114226 LatestCommit : "abcd" ,
115227 },
116228 ID : 1 ,
@@ -137,8 +249,16 @@ func TestCheckValidPayload(t *testing.T) {
137249 Name : "repo" ,
138250 },
139251 },
252+ LatestCommit : "abcd" ,
140253 },
141254 FromRef : bbv1.PullRequestRef {
255+ Repository : bbv1.Repository {
256+ Name : "repo" ,
257+ Project : & bbv1.Project {
258+ Key : "PROJ" ,
259+ Name : "repo" ,
260+ },
261+ },
142262 LatestCommit : "abcd" ,
143263 },
144264 ID : 1 ,
@@ -168,10 +288,20 @@ func TestCheckValidPayload(t *testing.T) {
168288 },
169289 },
170290 },
171- DisplayID : "main" ,
291+ DisplayID : "main" ,
292+ LatestCommit : "abcd" ,
293+ },
294+ FromRef : bbv1.PullRequestRef {
295+ Repository : bbv1.Repository {
296+ Name : "repo" ,
297+ Project : & bbv1.Project {
298+ Key : "PROJ" ,
299+ Name : "repo" ,
300+ },
301+ },
302+ LatestCommit : "abcd" ,
172303 },
173- FromRef : bbv1.PullRequestRef {LatestCommit : "latet" },
174- ID : 1 ,
304+ ID : 1 ,
175305 },
176306 },
177307 wantErrString : "bitbucket fromRef display ID is empty" ,
@@ -198,9 +328,17 @@ func TestCheckValidPayload(t *testing.T) {
198328 },
199329 },
200330 },
201- DisplayID : "main" ,
331+ DisplayID : "main" ,
332+ LatestCommit : "abcd" ,
202333 },
203334 FromRef : bbv1.PullRequestRef {
335+ Repository : bbv1.Repository {
336+ Name : "repo" ,
337+ Project : & bbv1.Project {
338+ Key : "PROJ" ,
339+ Name : "repo" ,
340+ },
341+ },
204342 DisplayID : "feature" ,
205343 LatestCommit : "abcd" ,
206344 },
@@ -231,12 +369,17 @@ func TestCheckValidPayload(t *testing.T) {
231369 },
232370 },
233371 },
234- DisplayID : "main" ,
372+ DisplayID : "main" ,
373+ LatestCommit : "abcd" ,
235374 },
236375 FromRef : bbv1.PullRequestRef {
237376 DisplayID : "feature" ,
238377 LatestCommit : "abcd" ,
239378 Repository : bbv1.Repository {
379+ Project : & bbv1.Project {
380+ Key : "PROJ" ,
381+ Name : "repo" ,
382+ },
240383 Links : & struct {
241384 Clone []bbv1.CloneLink `json:"clone,omitempty"`
242385 Self []bbv1.SelfLink `json:"self,omitempty"`
@@ -275,12 +418,17 @@ func TestCheckValidPayload(t *testing.T) {
275418 },
276419 },
277420 },
278- DisplayID : "main" ,
421+ DisplayID : "main" ,
422+ LatestCommit : "abcd" ,
279423 },
280424 FromRef : bbv1.PullRequestRef {
281425 DisplayID : "feature" ,
282426 LatestCommit : "abcd" ,
283427 Repository : bbv1.Repository {
428+ Project : & bbv1.Project {
429+ Key : "PROJ" ,
430+ Name : "repo" ,
431+ },
284432 Links : & struct {
285433 Clone []bbv1.CloneLink `json:"clone,omitempty"`
286434 Self []bbv1.SelfLink `json:"self,omitempty"`
0 commit comments