1
0
mirror of https://github.com/badges/shields.git synced 2025-04-18 19:44:04 +03:00
shields/services/bitbucket/bitbucket-pull-request.tester.js
Pierre-Yves Bigourdan cb2ebe2e94
migrate examples to openApi part 37; affects [bitbucket bitrise chromewebstore circleci] (#9881)
* migrate some services from examples to openApi

* Fix Bitbucket tests and examples

* Fix CircleCI and Bitrise tests

* Use fake token in Bitrise examples

* Use JohnEstropia/CoreStore token in Bitrise tests
2024-02-14 18:52:47 +00:00

109 lines
2.9 KiB
JavaScript

import { ServiceTester } from '../tester.js'
import { isMetric, isMetricOpenIssues } from '../test-validators.js'
export const t = new ServiceTester({
id: 'BitbucketPullRequest',
title: 'Bitbucket Pull Request',
pathPrefix: '/bitbucket',
})
t.create('pr-raw (valid)')
.get('/pr-raw/shields-io/test-repo.json')
.expectBadge({
label: 'pull requests',
message: isMetric,
})
t.create('pr-raw (not found)')
.get('/pr-raw/shields-io/not-a-repo.json')
.expectBadge({ label: 'pull requests', message: 'not found' })
t.create('pr-raw (private repo)')
.get('/pr-raw/chris48s/example-private-repo.json')
.expectBadge({ label: 'pull requests', message: 'not found' })
t.create('pr (valid)').get('/pr/shields-io/test-repo.json').expectBadge({
label: 'pull requests',
message: isMetricOpenIssues,
})
t.create('pr (not found)')
.get('/pr/shields-io/not-a-repo.json')
.expectBadge({ label: 'pull requests', message: 'not found' })
t.create('pr (private repo)')
.get('/pr/chris48s/example-private-repo.json')
.expectBadge({ label: 'pull requests', message: 'not found' })
t.create('pr (server)')
.get('/pr/project/repo.json?server=https://bitbucket.mydomain.net')
.intercept(nock =>
nock('https://bitbucket.mydomain.net/rest/api/1.0/projects')
.get('/project/repos/repo/pull-requests')
.query({
state: 'OPEN',
limit: 100,
withProperties: false,
withAttributes: false,
})
.reply(200, { size: 42 }),
)
.expectBadge({
label: 'pull requests',
message: isMetricOpenIssues,
})
t.create('pr (server, invalid credentials)')
.get('/pr/project/repo.json?server=https://bitbucket.mydomain.net')
.intercept(nock =>
nock('https://bitbucket.mydomain.net/rest/api/1.0/projects')
.get('/project/repos/repo/pull-requests')
.query({
state: 'OPEN',
limit: 100,
withProperties: false,
withAttributes: false,
})
.reply(401),
)
.expectBadge({
label: 'pull requests',
message: 'invalid credentials',
})
t.create('pr (server, private repo)')
.get('/pr/project/repo.json?server=https://bitbucket.mydomain.net')
.intercept(nock =>
nock('https://bitbucket.mydomain.net/rest/api/1.0/projects')
.get('/project/repos/repo/pull-requests')
.query({
state: 'OPEN',
limit: 100,
withProperties: false,
withAttributes: false,
})
.reply(403),
)
.expectBadge({
label: 'pull requests',
message: 'private repo',
})
t.create('pr (server, not found)')
.get('/pr/project/repo.json?server=https://bitbucket.mydomain.net')
.intercept(nock =>
nock('https://bitbucket.mydomain.net/rest/api/1.0/projects')
.get('/project/repos/repo/pull-requests')
.query({
state: 'OPEN',
limit: 100,
withProperties: false,
withAttributes: false,
})
.reply(404),
)
.expectBadge({
label: 'pull requests',
message: 'not found',
})