forked from octokit/octokit.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbranch-protection-test.js
83 lines (72 loc) · 2.08 KB
/
branch-protection-test.js
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
const {getInstance} = require('../util')
require('../mocha-node-setup')
describe('api.github.com', () => {
let github
beforeEach(() => {
return getInstance('branch-protection')
.then(instance => {
github = instance
github.authenticate({
type: 'token',
token: '0000000000000000000000000000000000000001'
})
})
})
it('github.repos.{get,update,remove}BranchProtection()', () => {
return github.repos.getBranchProtection({
owner: 'octokit-fixture-org',
repo: 'branch-protection',
branch: 'master'
})
.catch(error => {
if (/Branch not protected/.test(error.message)) {
return
}
throw error
})
.then(() => {
return github.repos.updateBranchProtection({
owner: 'octokit-fixture-org',
repo: 'branch-protection',
branch: 'master',
required_status_checks: null,
required_pull_request_reviews: null,
restrictions: null,
enforce_admins: false
})
})
.then(() => {
return github.repos.updateBranchProtection({
owner: 'octokit-fixture-org',
repo: 'branch-protection',
branch: 'master',
required_status_checks: {
strict: true,
contexts: [
'foo/bar'
]
},
required_pull_request_reviews: {
dismissal_restrictions: {
users: ['octokit-fixture-user-a'],
teams: [] // bug: server returns "Only 100 users and teams can be specified." when set to ['a-team']
},
dismiss_stale_reviews: true,
require_code_owner_reviews: false
},
restrictions: {
users: ['octokit-fixture-user-a'],
teams: ['a-team']
},
enforce_admins: true
})
})
.then(() => {
return github.repos.removeBranchProtection({
owner: 'octokit-fixture-org',
repo: 'branch-protection',
branch: 'master'
})
})
})
})