Skip to content
Snippets Groups Projects
Commit a505376c authored by Rhys Arkins's avatar Rhys Arkins
Browse files

tests: fix github datasource cache test

parent 0d767c59
No related branches found
No related tags found
No related merge requests found
......@@ -31,19 +31,3 @@ Object {
"repositoryUrl": "https://github.com/some/dep",
}
`;
exports[`datasource/github getPkgReleases returns releases from cache 1`] = `
Object {
"releases": Array [
Object {
"gitRef": "1.0.0",
"version": "1.0.0",
},
Object {
"gitRef": "v1.1.0",
"version": "v1.1.0",
},
],
"repositoryUrl": "https://github.com/some/dep",
}
`;
......@@ -8,6 +8,7 @@ jest.mock('../../lib/platform/github/gh-got-wrapper');
jest.mock('got');
describe('datasource/github', () => {
beforeEach(() => global.renovateCache.rmAll());
describe('getPreset()', () => {
it('throws if non-default', async () => {
await expect(
......@@ -75,15 +76,21 @@ describe('datasource/github', () => {
).toBeDefined();
});
it('returns releases from cache', async () => {
await delay(1000);
const res = await datasource.getPkgReleases(
'pkg:github/some/dep?ref=release'
const body = [
{ tag_name: 'a' },
{ tag_name: 'v' },
{ tag_name: '1.0.0' },
{ tag_name: 'v1.1.0' },
];
ghGot.mockReturnValueOnce({ headers: {}, body });
const res1 = await datasource.getPkgReleases(
'pkg:github/some/dep-to-cache?ref=release'
);
expect(res).toMatchSnapshot();
expect(res.releases).toHaveLength(2);
expect(
res.releases.find(release => release.version === 'v1.1.0')
).toBeDefined();
expect(res1.releases).toHaveLength(2);
const res2 = await datasource.getPkgReleases(
'pkg:github/some/dep-to-cache?ref=release'
);
expect(res1).toEqual(res2);
});
it('returns null for invalid ref', async () => {
expect(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment