mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 09:06:25 +00:00
93dd940574
* fix null-check issues * Update index.spec.ts * apply suggestion from review * fix coverage issue * Update index.spec.ts * Apply suggestions from code review Co-authored-by: Michael Kriese <michael.kriese@visualon.de> * Update datasource.spec.ts * Update lib/modules/datasource/conan/index.spec.ts Co-authored-by: Michael Kriese <michael.kriese@visualon.de> * Update datasource.spec.ts * fix null-check issue Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
36 lines
990 B
TypeScript
36 lines
990 B
TypeScript
import * as httpMock from '../../../test/http-mock';
|
|
import { partial } from '../../../test/util';
|
|
import { EXTERNAL_HOST_ERROR } from '../../constants/error-messages';
|
|
import { Datasource } from './datasource';
|
|
import type { GetReleasesConfig, ReleaseResult } from './types';
|
|
|
|
const exampleUrl = 'https://example.com/';
|
|
|
|
class TestDatasource extends Datasource {
|
|
constructor() {
|
|
super('test');
|
|
}
|
|
|
|
async getReleases(
|
|
getReleasesConfig: GetReleasesConfig
|
|
): Promise<ReleaseResult | null> {
|
|
try {
|
|
await this.http.get(exampleUrl);
|
|
} catch (err) {
|
|
this.handleGenericErrors(err);
|
|
}
|
|
return Promise.resolve(null);
|
|
}
|
|
}
|
|
|
|
describe('modules/datasource/datasource', () => {
|
|
it('should throw on 429', async () => {
|
|
const testDatasource = new TestDatasource();
|
|
|
|
httpMock.scope(exampleUrl).get('/').reply(429);
|
|
|
|
await expect(
|
|
testDatasource.getReleases(partial<GetReleasesConfig>({}))
|
|
).rejects.toThrow(EXTERNAL_HOST_ERROR);
|
|
});
|
|
});
|