forked from renovatebot/renovate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitea-helper.spec.ts
810 lines (706 loc) · 21.8 KB
/
gitea-helper.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
import * as httpMock from '../../../../test/http-mock';
import { setBaseUrl } from '../../../util/http/gitea';
import { toBase64 } from '../../../util/string';
import {
assignLabel,
closeIssue,
closePR,
createComment,
createCommitStatus,
createIssue,
createPR,
deleteComment,
getBranch,
getCombinedCommitStatus,
getComments,
getCurrentUser,
getIssue,
getOrgLabels,
getPR,
getRepo,
getRepoContents,
getRepoLabels,
getVersion,
mergePR,
requestPrReviewers,
searchIssues,
searchPRs,
searchRepos,
unassignLabel,
updateComment,
updateIssue,
updateIssueLabels,
updatePR,
} from './gitea-helper';
import type {
Branch,
Comment,
Commit,
CommitStatus,
CommitStatusType,
Issue,
Label,
PR,
Repo,
RepoContents,
User,
} from './types';
describe('modules/platform/gitea/gitea-helper', () => {
const giteaApiHost = 'https://gitea.renovatebot.com/';
const baseUrl = `${giteaApiHost}api/v1`;
const mockCommitHash = '0d9c7726c3d628b7e28af234595cfd20febdbf8e';
const mockUser: User = {
id: 1,
username: 'admin',
full_name: 'The Administrator',
email: 'admin@example.com',
};
const otherMockUser: User & Required<Pick<User, 'full_name'>> = {
...mockUser,
username: 'renovate',
full_name: 'Renovate Bot',
email: 'renovate@example.com',
};
const mockRepo: Repo = {
id: 123,
allow_rebase: true,
allow_rebase_explicit: true,
allow_merge_commits: true,
allow_squash_merge: true,
clone_url: 'https://gitea.renovatebot.com/some/repo.git',
ssh_url: 'git@gitea.renovatebot.com/some/repo.git',
default_branch: 'master',
full_name: 'some/repo',
archived: false,
mirror: false,
empty: false,
fork: false,
owner: mockUser,
permissions: {
pull: true,
push: true,
admin: false,
},
};
const otherMockRepo: Repo = {
...mockRepo,
full_name: 'other/repo',
clone_url: 'https://gitea.renovatebot.com/other/repo.git',
};
const mockLabel: Label = {
id: 100,
name: 'some-label',
description: 'just a label',
color: '#000000',
};
const otherMockLabel: Label = {
...mockLabel,
id: 200,
name: 'other-label',
};
const mockPR: PR = {
number: 13,
state: 'open',
title: 'Some PR',
body: 'Lorem ipsum dolor sit amet',
mergeable: true,
diff_url: `https://gitea.renovatebot.com/${mockRepo.full_name}/pulls/13.diff`,
base: { ref: mockRepo.default_branch },
head: {
label: 'pull-req-13',
sha: mockCommitHash,
repo: mockRepo,
},
created_at: '2018-08-13T20:45:37Z',
closed_at: '2020-04-01T19:19:22Z',
};
const mockIssue: Issue = {
number: 7,
state: 'open',
title: 'Some Issue',
body: 'just some issue',
assignees: [mockUser],
labels: [],
};
const mockComment: Comment = {
id: 31,
body: 'some-comment',
};
const mockCommitStatus: CommitStatus = {
id: 121,
status: 'success',
context: 'some-context',
description: 'some-description',
target_url: 'https://gitea.renovatebot.com/commit-status',
created_at: '2020-03-25T00:00:00Z',
};
const otherMockCommitStatus: CommitStatus = {
...mockCommitStatus,
id: 242,
status: 'error',
context: 'other-context',
};
const mockCommit: Commit = {
id: mockCommitHash,
author: {
name: otherMockUser.full_name,
email: otherMockUser.email,
username: otherMockUser.username,
},
};
const mockBranch: Branch = {
name: 'some-branch',
commit: mockCommit,
};
const otherMockBranch: Branch = {
...mockBranch,
name: 'other/branch/with/slashes',
};
const mockContents: RepoContents = {
path: 'dummy.txt',
content: toBase64('top secret'),
contentString: 'top secret',
};
const otherMockContents: RepoContents = {
...mockContents,
path: 'nested/path/dummy.txt',
};
beforeEach(() => {
setBaseUrl(giteaApiHost);
});
describe('getCurrentUser', () => {
it('should call /api/v1/user endpoint', async () => {
httpMock.scope(baseUrl).get('/user').reply(200, mockUser);
const res = await getCurrentUser();
expect(res).toEqual(mockUser);
});
});
describe('getVersion', () => {
it('should call /api/v1/version endpoint', async () => {
const version = '1.13.01.14.0+dev-754-g5d2b7ba63';
httpMock.scope(baseUrl).get('/version').reply(200, { version });
const res = await getVersion();
expect(res).toEqual(version);
});
});
describe('searchRepos', () => {
it('should call /api/v1/repos/search endpoint', async () => {
httpMock
.scope(baseUrl)
.get('/repos/search')
.reply(200, {
ok: true,
data: [mockRepo, otherMockRepo],
});
const res = await searchRepos({});
expect(res).toEqual([mockRepo, otherMockRepo]);
});
it('should construct proper query parameters', async () => {
httpMock
.scope(baseUrl)
.get('/repos/search?uid=13&archived=false')
.reply(200, {
ok: true,
data: [otherMockRepo],
});
const res = await searchRepos({
uid: 13,
archived: false,
});
expect(res).toEqual([otherMockRepo]);
});
it('should abort if ok flag was not set', async () => {
httpMock.scope(baseUrl).get('/repos/search').reply(200, {
ok: false,
data: [],
});
await expect(searchRepos({})).rejects.toThrow();
});
});
describe('getRepo', () => {
it('should call /api/v1/repos/[repo] endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}`)
.reply(200, mockRepo);
const res = await getRepo(mockRepo.full_name);
expect(res).toEqual(mockRepo);
});
});
describe('getRepoContents', () => {
it('should call /api/v1/repos/[repo]/contents/[file] endpoint', async () => {
// The official API only returns the base64-encoded content, so we strip `contentString`
// from our mock to verify base64 decoding.
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/contents/${mockContents.path}`)
.reply(200, { ...mockContents, contentString: undefined });
const res = await getRepoContents(mockRepo.full_name, mockContents.path);
expect(res).toEqual(mockContents);
});
it('should support passing reference by query', async () => {
httpMock
.scope(baseUrl)
.get(
`/repos/${mockRepo.full_name}/contents/${mockContents.path}?ref=${mockCommitHash}`
)
.reply(200, { ...mockContents, contentString: undefined });
const res = await getRepoContents(
mockRepo.full_name,
mockContents.path,
mockCommitHash
);
expect(res).toEqual(mockContents);
});
it('should properly escape paths', async () => {
const escapedPath = encodeURIComponent(otherMockContents.path);
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/contents/${escapedPath}`)
.reply(200, otherMockContents);
const res = await getRepoContents(
mockRepo.full_name,
otherMockContents.path
);
expect(res).toEqual(otherMockContents);
});
it('should not fail if no content is returned', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/contents/${mockContents.path}`)
.reply(200, {
...mockContents,
content: undefined,
contentString: undefined,
});
const res = await getRepoContents(mockRepo.full_name, mockContents.path);
expect(res).toEqual({
...mockContents,
content: undefined,
contentString: undefined,
});
});
});
describe('createPR', () => {
it('should call /api/v1/repos/[repo]/pulls endpoint', async () => {
httpMock
.scope(baseUrl)
.post(`/repos/${mockRepo.full_name}/pulls`)
.reply(200, mockPR);
const res = await createPR(mockRepo.full_name, {
state: mockPR.state,
title: mockPR.title,
body: mockPR.body,
base: mockPR.base?.ref,
head: mockPR.head?.label,
assignees: [mockUser.username],
labels: [mockLabel.id],
});
expect(res).toEqual(mockPR);
});
});
describe('updatePR', () => {
it('should call /api/v1/repos/[repo]/pulls/[pull] endpoint', async () => {
const updatedMockPR: PR = {
...mockPR,
state: 'closed',
title: 'new-title',
body: 'new-body',
};
httpMock
.scope(baseUrl)
.patch(`/repos/${mockRepo.full_name}/pulls/${mockPR.number}`)
.reply(200, updatedMockPR);
const res = await updatePR(mockRepo.full_name, mockPR.number, {
state: 'closed',
title: 'new-title',
body: 'new-body',
assignees: [otherMockUser.username],
labels: [otherMockLabel.id],
});
expect(res).toEqual(updatedMockPR);
});
});
describe('closePR', () => {
it('should call /api/v1/repos/[repo]/pulls/[pull] endpoint', async () => {
httpMock
.scope(baseUrl)
.patch(`/repos/${mockRepo.full_name}/pulls/${mockPR.number}`)
.reply(200);
const res = await closePR(mockRepo.full_name, mockPR.number);
expect(res).toBeUndefined();
});
});
describe('mergePR', () => {
it('should call /api/v1/repos/[repo]/pulls/[pull]/merge endpoint', async () => {
httpMock
.scope(baseUrl)
.post(`/repos/${mockRepo.full_name}/pulls/${mockPR.number}/merge`)
.reply(200);
const res = await mergePR(mockRepo.full_name, mockPR.number, {
Do: 'rebase',
});
expect(res).toBeUndefined();
});
});
describe('getPR', () => {
it('should call /api/v1/repos/[repo]/pulls/[pull] endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/pulls/${mockPR.number}`)
.reply(200, mockPR);
const res = await getPR(mockRepo.full_name, mockPR.number);
expect(res).toEqual(mockPR);
});
});
describe('addReviewers', () => {
it('should call /api/v1/repos/[repo]/pulls/[pull]/requested_reviewers endpoint', async () => {
httpMock
.scope(baseUrl)
.post(
`/repos/${mockRepo.full_name}/pulls/${mockPR.number}/requested_reviewers`
)
.reply(200);
await expect(
requestPrReviewers(mockRepo.full_name, mockPR.number, {})
).toResolve();
});
});
describe('searchPRs', () => {
it('should call /api/v1/repos/[repo]/pulls endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/pulls`)
.reply(200, [mockPR]);
const res = await searchPRs(mockRepo.full_name, {});
expect(res).toEqual([mockPR]);
});
it('should construct proper query parameters', async () => {
httpMock
.scope(baseUrl)
.get(
`/repos/${mockRepo.full_name}/pulls?state=open&labels=${mockLabel.id}&labels=${otherMockLabel.id}`
)
.reply(200, [mockPR]);
const res = await searchPRs(mockRepo.full_name, {
state: 'open',
labels: [mockLabel.id, otherMockLabel.id],
});
expect(res).toEqual([mockPR]);
});
});
describe('createIssue', () => {
it('should call /api/v1/repos/[repo]/issues endpoint', async () => {
httpMock
.scope(baseUrl)
.post(`/repos/${mockRepo.full_name}/issues`)
.reply(200, mockIssue);
const res = await createIssue(mockRepo.full_name, {
state: mockIssue.state,
title: mockIssue.title,
body: mockIssue.body,
assignees: [mockUser.username],
});
expect(res).toEqual(mockIssue);
});
});
describe('updateIssue', () => {
it('should call /api/v1/repos/[repo]/issues/[issue] endpoint', async () => {
const updatedMockIssue: Issue = {
...mockIssue,
state: 'closed',
title: 'new-title',
body: 'new-body',
assignees: [otherMockUser],
};
httpMock
.scope(baseUrl)
.patch(`/repos/${mockRepo.full_name}/issues/${mockIssue.number}`)
.reply(200, updatedMockIssue);
const res = await updateIssue(mockRepo.full_name, mockIssue.number, {
state: 'closed',
title: 'new-title',
body: 'new-body',
assignees: [otherMockUser.username],
});
expect(res).toEqual(updatedMockIssue);
});
});
describe('updateIssueLabels', () => {
it('should call /api/v1/repos/[repo]/issues/[issue]/labels endpoint', async () => {
const updatedMockLabels: Partial<Label>[] = [
{ id: 1, name: 'Renovate' },
{ id: 3, name: 'Maintenance' },
];
httpMock
.scope(baseUrl)
.put(`/repos/${mockRepo.full_name}/issues/${mockIssue.number}/labels`)
.reply(200, updatedMockLabels);
const res = await updateIssueLabels(
mockRepo.full_name,
mockIssue.number,
{
labels: [1, 3],
}
);
expect(res).toEqual(updatedMockLabels);
});
});
describe('closeIssue', () => {
it('should call /api/v1/repos/[repo]/issues/[issue] endpoint', async () => {
httpMock
.scope(baseUrl)
.patch(`/repos/${mockRepo.full_name}/issues/${mockIssue.number}`)
.reply(200);
const res = await closeIssue(mockRepo.full_name, mockIssue.number);
expect(res).toBeUndefined();
});
});
describe('searchIssues', () => {
it('should call /api/v1/repos/[repo]/issues endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/issues?type=issues`)
.reply(200, [mockIssue]);
const res = await searchIssues(mockRepo.full_name, {});
expect(res).toEqual([mockIssue]);
});
it('should construct proper query parameters', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/issues?state=open&type=issues`)
.reply(200, [mockIssue]);
const res = await searchIssues(mockRepo.full_name, {
state: 'open',
});
expect(res).toEqual([mockIssue]);
});
});
describe('getIssue', () => {
it('should call /api/v1/repos/[repo]/issues/[issue] endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/issues/${mockIssue.number}`)
.reply(200, mockIssue);
const res = await getIssue(mockRepo.full_name, mockIssue.number);
expect(res).toEqual(mockIssue);
});
});
describe('getRepoLabels', () => {
it('should call /api/v1/repos/[repo]/labels endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/labels`)
.reply(200, [mockLabel, otherMockLabel]);
const res = await getRepoLabels(mockRepo.full_name);
expect(res).toEqual([mockLabel, otherMockLabel]);
});
});
describe('getOrgLabels', () => {
it('should call /api/v1/orgs/[org]/labels endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/orgs/${mockRepo.owner.username}/labels`)
.reply(200, [mockLabel, otherMockLabel]);
const res = await getOrgLabels(mockRepo.owner.username);
expect(res).toEqual([mockLabel, otherMockLabel]);
});
});
describe('unassignLabel', () => {
it('should call /api/v1/repos/[repo]/issues/[issue]/labels/[label] endpoint', async () => {
httpMock
.scope(baseUrl)
.delete(
`/repos/${mockRepo.full_name}/issues/${mockIssue.number}/labels/${mockLabel.id}`
)
.reply(200);
const res = await unassignLabel(
mockRepo.full_name,
mockIssue.number,
mockLabel.id
);
expect(res).toBeUndefined();
});
});
describe('assignLabel', () => {
it('should call /api/v1/repos/[repo]/issues/[issue]/labels endpoint', async () => {
httpMock
.scope(baseUrl)
.patch(`/repos/${mockRepo.full_name}/issues/${mockIssue.number}/labels`)
.reply(200);
const res = await assignLabel(
mockRepo.full_name,
mockIssue.number,
mockLabel.id
);
expect(res).toBeUndefined();
});
});
describe('createComment', () => {
it('should call /api/v1/repos/[repo]/issues/[issue]/comments endpoint', async () => {
httpMock
.scope(baseUrl)
.post(
`/repos/${mockRepo.full_name}/issues/${mockIssue.number}/comments`
)
.reply(200, mockComment);
const res = await createComment(
mockRepo.full_name,
mockIssue.number,
mockComment.body
);
expect(res).toEqual(mockComment);
});
});
describe('updateComment', () => {
it('should call /api/v1/repos/[repo]/issues/comments/[comment] endpoint', async () => {
const updatedMockComment: Comment = {
...mockComment,
body: 'new-body',
};
httpMock
.scope(baseUrl)
.patch(`/repos/${mockRepo.full_name}/issues/comments/${mockComment.id}`)
.reply(200, updatedMockComment);
const res = await updateComment(
mockRepo.full_name,
mockComment.id,
'new-body'
);
expect(res).toEqual(updatedMockComment);
});
});
describe('deleteComment', () => {
it('should call /api/v1/repos/[repo]/issues/comments/[comment] endpoint', async () => {
httpMock
.scope(baseUrl)
.delete(
`/repos/${mockRepo.full_name}/issues/comments/${mockComment.id}`
)
.reply(200);
const res = await deleteComment(mockRepo.full_name, mockComment.id);
expect(res).toBeUndefined();
});
});
describe('getComments', () => {
it('should call /api/v1/repos/[repo]/issues/[issue]/comments endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/issues/${mockIssue.number}/comments`)
.reply(200, [mockComment]);
const res = await getComments(mockRepo.full_name, mockIssue.number);
expect(res).toEqual([mockComment]);
});
});
describe('createCommitStatus', () => {
it('should call /api/v1/repos/[repo]/statuses/[commit] endpoint', async () => {
httpMock
.scope(baseUrl)
.post(`/repos/${mockRepo.full_name}/statuses/${mockCommitHash}`)
.reply(200, mockCommitStatus);
const res = await createCommitStatus(mockRepo.full_name, mockCommitHash, {
state: mockCommitStatus.status,
context: mockCommitStatus.context,
description: mockCommitStatus.description,
target_url: mockCommitStatus.target_url,
});
expect(res).toEqual(mockCommitStatus);
});
});
describe('getCombinedCommitStatus', () => {
it('should call /api/v1/repos/[repo]/commits/[branch]/statuses endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/commits/${mockBranch.name}/statuses`)
.reply(200, [mockCommitStatus, otherMockCommitStatus]);
const res = await getCombinedCommitStatus(
mockRepo.full_name,
mockBranch.name
);
expect(res.worstStatus).not.toBe('unknown');
expect(res.statuses).toEqual([mockCommitStatus, otherMockCommitStatus]);
});
it('should properly determine worst commit status', async () => {
const statuses: {
status: CommitStatusType;
created_at: string;
expected: CommitStatusType;
}[] = [
{
status: 'unknown',
created_at: '2020-03-25T01:00:00Z',
expected: 'unknown',
},
{
status: 'pending',
created_at: '2020-03-25T03:00:00Z',
expected: 'pending',
},
{
status: 'warning',
created_at: '2020-03-25T04:00:00Z',
expected: 'warning',
},
{
status: 'failure',
created_at: '2020-03-25T05:00:00Z',
expected: 'failure',
},
{
status: 'success',
created_at: '2020-03-25T02:00:00Z',
expected: 'failure',
},
{
status: 'success',
created_at: '2020-03-25T06:00:00Z',
expected: 'success',
},
];
const commitStatuses: CommitStatus[] = [
{ ...mockCommitStatus, status: 'unknown' },
];
for (const statusElem of statuses) {
const { status, expected } = statusElem;
// Add current status ot list of commit statuses, then mock the API to return the whole list
commitStatuses.push({
...mockCommitStatus,
status,
created_at: statusElem.created_at,
});
httpMock
.scope(baseUrl)
.get(
`/repos/${mockRepo.full_name}/commits/${mockBranch.name}/statuses`
)
.reply(200, commitStatuses);
// Expect to get the current state back as the worst status, as all previous commit statuses
// should be less important than the one which just got added
const res = await getCombinedCommitStatus(
mockRepo.full_name,
mockBranch.name
);
expect(res.worstStatus).toEqual(expected);
}
});
});
describe('getBranch', () => {
it('should call /api/v1/repos/[repo]/branches/[branch] endpoint', async () => {
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/branches/${mockBranch.name}`)
.reply(200, mockBranch);
const res = await getBranch(mockRepo.full_name, mockBranch.name);
expect(res).toEqual(mockBranch);
});
it('should properly escape branch names', async () => {
const escapedBranchName = encodeURIComponent(otherMockBranch.name);
httpMock
.scope(baseUrl)
.get(`/repos/${mockRepo.full_name}/branches/${escapedBranchName}`)
.reply(200, otherMockBranch);
const res = await getBranch(mockRepo.full_name, otherMockBranch.name);
expect(res).toEqual(otherMockBranch);
});
});
});