mirror of
https://github.com/gradle/actions.git
synced 2026-02-04 23:34:28 +08:00
Avoid open interceptors in unit test
This commit is contained in:
parent
f29f5a9d7b
commit
49ec880f92
@ -31,30 +31,6 @@ describe('short lived tokens', () => {
|
|||||||
expect(develocityAccessCredentials?.raw()).toBe('host1=key1;host2=key2')
|
expect(develocityAccessCredentials?.raw()).toBe('host1=key1;host2=key2')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('get short lived token fails when cannot connect', async () => {
|
|
||||||
nock('http://localhost:3333')
|
|
||||||
.post('/api/auth/token')
|
|
||||||
.times(3)
|
|
||||||
.replyWithError({
|
|
||||||
message: 'connect ECONNREFUSED 127.0.0.1:3333',
|
|
||||||
code: 'ECONNREFUSED'
|
|
||||||
})
|
|
||||||
await expect(getToken('localhost=key0', false, ''))
|
|
||||||
.resolves
|
|
||||||
.toBeNull()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('get short lived token is null when request fails', async () => {
|
|
||||||
nock('http://dev:3333')
|
|
||||||
.post('/api/auth/token')
|
|
||||||
.times(3)
|
|
||||||
.reply(500, 'Internal error')
|
|
||||||
expect.assertions(1)
|
|
||||||
await expect(getToken('dev=xyz', false, ''))
|
|
||||||
.resolves
|
|
||||||
.toBeNull()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('get short lived token returns null when access key is empty', async () => {
|
it('get short lived token returns null when access key is empty', async () => {
|
||||||
expect.assertions(1)
|
expect.assertions(1)
|
||||||
await expect(getToken('', false, ''))
|
await expect(getToken('', false, ''))
|
||||||
@ -127,3 +103,34 @@ describe('short lived tokens', () => {
|
|||||||
.toEqual({"keys": [{"hostname": "dev", "key": "token"}]})
|
.toEqual({"keys": [{"hostname": "dev", "key": "token"}]})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('short lived tokens with retry', () => {
|
||||||
|
afterEach(() => {
|
||||||
|
nock.cleanAll()
|
||||||
|
nock.restore()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('get short lived token fails when cannot connect', async () => {
|
||||||
|
nock('http://localhost:3333')
|
||||||
|
.post('/api/auth/token')
|
||||||
|
.times(3)
|
||||||
|
.replyWithError({
|
||||||
|
message: 'connect ECONNREFUSED 127.0.0.1:3333',
|
||||||
|
code: 'ECONNREFUSED'
|
||||||
|
})
|
||||||
|
await expect(getToken('localhost=key0', false, ''))
|
||||||
|
.resolves
|
||||||
|
.toBeNull()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('get short lived token is null when request fails', async () => {
|
||||||
|
nock('http://dev:3333')
|
||||||
|
.post('/api/auth/token')
|
||||||
|
.times(3)
|
||||||
|
.reply(500, 'Internal error')
|
||||||
|
expect.assertions(1)
|
||||||
|
await expect(getToken('dev=xyz', false, ''))
|
||||||
|
.resolves
|
||||||
|
.toBeNull()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@ -58,6 +58,7 @@ test('fetches wrapper jar checksums for snapshots', async () => {
|
|||||||
describe('retry', () => {
|
describe('retry', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
nock.cleanAll()
|
nock.cleanAll()
|
||||||
|
nock.restore()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('for /versions/all API', () => {
|
describe('for /versions/all API', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user