Skip to content

Commit 0cb6f17

Browse files
authored
fix: problem when diffs got no hunks (#103)
* fix: problem when diffs got no hunks + add tests * test(BitBucketApiMock): change diffsNoHunks
1 parent 22282a2 commit 0cb6f17

File tree

6 files changed

+198
-113
lines changed

6 files changed

+198
-113
lines changed

src/BitBucketHealth-Model-Importer-Tests/BitBucketApiMock.class.st

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
Class {
2-
#name : 'BitBucketApiMock',
3-
#superclass : 'Object',
2+
#name : #BitBucketApiMock,
3+
#superclass : #Object,
44
#instVars : [
55
'userMock',
66
'commits',
77
'diffs',
88
'mergeRequests'
99
],
10-
#category : 'BitBucketHealth-Model-Importer-Tests',
11-
#package : 'BitBucketHealth-Model-Importer-Tests'
10+
#category : #'BitBucketHealth-Model-Importer-Tests'
1211
}
1312

14-
{ #category : 'api - pull-requests' }
13+
{ #category : #'api - pull-requests' }
1514
BitBucketApiMock >> activitiesOfPullRequest: pullRequestId inRepoProjectId: repoSlug ofProjectGroupId: projectKey [
1615

1716
^self pullRequestActivities
1817
]
1918

20-
{ #category : 'accessing' }
19+
{ #category : #accessing }
2120
BitBucketApiMock >> commit2 [
2221

2322
| commits2 |
@@ -49,13 +48,13 @@ BitBucketApiMock >> commit2 [
4948
^ commits2 := (NeoJSONReader on: commits2 readStream) next
5049
]
5150

52-
{ #category : 'accessing' }
51+
{ #category : #accessing }
5352
BitBucketApiMock >> commits [
5453

5554
^ commits
5655
]
5756

58-
{ #category : 'accessing' }
57+
{ #category : #accessing }
5958
BitBucketApiMock >> commits1 [
6059

6160
| commits1 |
@@ -87,19 +86,19 @@ BitBucketApiMock >> commits1 [
8786
^ commits1 := (NeoJSONReader on: commits1 readStream) next
8887
]
8988

90-
{ #category : 'accessing' }
89+
{ #category : #accessing }
9190
BitBucketApiMock >> commits: anObject [
9291

9392
commits := anObject
9493
]
9594

96-
{ #category : 'api - pull-requests' }
95+
{ #category : #'api - pull-requests' }
9796
BitBucketApiMock >> commitsOfPullRequest: mergeRequestId ofRepoProjectId: repoSlug inProjectGroupId: projectKey [
9897

9998
^commits
10099
]
101100

102-
{ #category : 'api - projects' }
101+
{ #category : #'api - projects' }
103102
BitBucketApiMock >> commitsOfRepoProjectId: repositorySlug inProjectGroupId: projectKey since: since until: until [
104103

105104
^ self commits select: [ :commit |
@@ -111,7 +110,7 @@ BitBucketApiMock >> commitsOfRepoProjectId: repositorySlug inProjectGroupId: pro
111110
commitDate >= since asDate and: commitDate <= until asDate ]
112111
]
113112

114-
{ #category : 'accessing' }
113+
{ #category : #accessing }
115114
BitBucketApiMock >> declinedMergeRequest [
116115

117116
| pullRequest |
@@ -307,13 +306,13 @@ BitBucketApiMock >> declinedMergeRequest [
307306
^ pullRequest := (NeoJSONReader on: pullRequest readStream) next
308307
]
309308

310-
{ #category : 'accessing' }
309+
{ #category : #accessing }
311310
BitBucketApiMock >> diffs [
312311

313312
^ diffs
314313
]
315314

316-
{ #category : 'accessing' }
315+
{ #category : #accessing }
317316
BitBucketApiMock >> diffs1 [
318317

319318
| diffs1 |
@@ -410,18 +409,49 @@ BitBucketApiMock >> diffs1 [
410409
^ diffs1 := (NeoJSONReader on: diffs1 readStream) next
411410
]
412411

413-
{ #category : 'accessing' }
412+
{ #category : #accessing }
414413
BitBucketApiMock >> diffs: anObject [
415414

416415
diffs := anObject
417416
]
418417

419-
{ #category : 'api - commits' }
418+
{ #category : #accessing }
419+
BitBucketApiMock >> diffsNohunks [
420+
421+
| diffs1 |
422+
diffs1 := '{
423+
"fromHash": null,
424+
"toHash": "123",
425+
"contextLines": 10,
426+
"whitespace": "SHOW",
427+
"diffs": [
428+
{
429+
"source": null,
430+
"destination": {
431+
"components": [
432+
"api",
433+
"api.xlsx"
434+
],
435+
"parent": "api",
436+
"name": "api.xlsx",
437+
"extension": "xlsx",
438+
"toString": "api/api.xlsx"
439+
},
440+
"binary": true
441+
}
442+
],
443+
"truncated": false
444+
}'.
445+
446+
^ diffs1 := (NeoJSONReader on: diffs1 readStream) next
447+
]
448+
449+
{ #category : #'api - commits' }
420450
BitBucketApiMock >> diffsOfCommit: commitID inRepoProjectId: repositorySlug inProjectGroupId: projectKey [
421451
^diffs
422452
]
423453

424-
{ #category : 'accessing' }
454+
{ #category : #accessing }
425455
BitBucketApiMock >> diffsWithoutAdded [
426456

427457
| diffsWithoutAdded |
@@ -519,7 +549,7 @@ BitBucketApiMock >> diffsWithoutAdded [
519549
diffsWithoutAdded readStream) next
520550
]
521551

522-
{ #category : 'accessing' }
552+
{ #category : #accessing }
523553
BitBucketApiMock >> diffsWithoutHunks [
524554

525555
| diffsWithoutHunks |
@@ -559,7 +589,7 @@ BitBucketApiMock >> diffsWithoutHunks [
559589
diffsWithoutHunks readStream) next
560590
]
561591

562-
{ #category : 'accessing' }
592+
{ #category : #accessing }
563593
BitBucketApiMock >> diffsWithoutRemoved [
564594

565595
| diffsWithoutRemoved |
@@ -645,7 +675,7 @@ BitBucketApiMock >> diffsWithoutRemoved [
645675
diffsWithoutRemoved readStream) next
646676
]
647677

648-
{ #category : 'initialization' }
678+
{ #category : #initialization }
649679
BitBucketApiMock >> initialize [
650680

651681
commits := self commits1.
@@ -654,19 +684,19 @@ BitBucketApiMock >> initialize [
654684
mergeRequests := { self openedMergeRequest }
655685
]
656686

657-
{ #category : 'accessing' }
687+
{ #category : #accessing }
658688
BitBucketApiMock >> mergeRequests [
659689

660690
^ mergeRequests
661691
]
662692

663-
{ #category : 'accessing' }
693+
{ #category : #accessing }
664694
BitBucketApiMock >> mergeRequests: anObject [
665695

666696
mergeRequests := anObject
667697
]
668698

669-
{ #category : 'accessing' }
699+
{ #category : #accessing }
670700
BitBucketApiMock >> mergedMergeRequest [
671701

672702
| pullRequest |
@@ -862,7 +892,7 @@ BitBucketApiMock >> mergedMergeRequest [
862892
^ pullRequest := (NeoJSONReader on: pullRequest readStream) next
863893
]
864894

865-
{ #category : 'accessing' }
895+
{ #category : #accessing }
866896
BitBucketApiMock >> openedMergeRequest [
867897

868898
| pullRequest |
@@ -1057,7 +1087,7 @@ BitBucketApiMock >> openedMergeRequest [
10571087
^pullRequest := (NeoJSONReader on: pullRequest readStream) next.
10581088
]
10591089

1060-
{ #category : 'accessing' }
1090+
{ #category : #accessing }
10611091
BitBucketApiMock >> projects [
10621092

10631093
| projects |
@@ -1081,7 +1111,7 @@ BitBucketApiMock >> projects [
10811111
^ projects
10821112
]
10831113

1084-
{ #category : 'accessing' }
1114+
{ #category : #accessing }
10851115
BitBucketApiMock >> pullRequestActivities [
10861116

10871117
| pullRequestActivities |
@@ -1112,13 +1142,13 @@ BitBucketApiMock >> pullRequestActivities [
11121142
pullRequestActivities readStream) next
11131143
]
11141144

1115-
{ #category : 'api - pull-requests' }
1145+
{ #category : #'api - pull-requests' }
11161146
BitBucketApiMock >> pullRequestsOfRepoProjectId: repoSlug inProjectGroupId: projectKey since: since until: until [
11171147

11181148
^ mergeRequests
11191149
]
11201150

1121-
{ #category : 'api - projects' }
1151+
{ #category : #'api - projects' }
11221152
BitBucketApiMock >> repositoryProjectsOfProjectGroupId: projectKey [
11231153

11241154
| repos |
@@ -1158,7 +1188,7 @@ repos := (NeoJSONReader on: repos readStream) next.
11581188
^repos
11591189
]
11601190

1161-
{ #category : 'accessing' }
1191+
{ #category : #accessing }
11621192
BitBucketApiMock >> user1 [
11631193

11641194
| user1 |
@@ -1190,7 +1220,7 @@ BitBucketApiMock >> user1 [
11901220
^ user1 := (NeoJSONReader on: user1 readStream) next
11911221
]
11921222

1193-
{ #category : 'accessing' }
1223+
{ #category : #accessing }
11941224
BitBucketApiMock >> user: accountId [
11951225

11961226
| user |
@@ -1205,19 +1235,19 @@ BitBucketApiMock >> user: accountId [
12051235
^ user
12061236
]
12071237

1208-
{ #category : 'accessing' }
1238+
{ #category : #accessing }
12091239
BitBucketApiMock >> userMock [
12101240

12111241
^ userMock
12121242
]
12131243

1214-
{ #category : 'accessing' }
1244+
{ #category : #accessing }
12151245
BitBucketApiMock >> userMock: anObject [
12161246

12171247
userMock := anObject
12181248
]
12191249

1220-
{ #category : 'api - user' }
1250+
{ #category : #'api - user' }
12211251
BitBucketApiMock >> usersByUsername: username [
12221252

12231253
userMock ifNil: [ ^Array new ] ifNotNil: [ ^{ userMock }]

0 commit comments

Comments
 (0)