Skip to content

Commit

Permalink
fix(go): handle null (#8861)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Feb 25, 2021
1 parent c3c04ba commit fd276e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/datasource/go/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getPkgReleases } from '..';
import * as httpMock from '../../../test/http-mock';
import { logger } from '../../../test/util';
import { id as datasource, getDigest } from '.';

const res1 = `<!DOCTYPE html>
Expand Down Expand Up @@ -223,6 +224,12 @@ describe('datasource/go', () => {
expect(res).toMatchSnapshot();
expect(res).toBeNull();
expect(httpMock.getTrace()).toMatchSnapshot();
expect(logger.logger.warn).toHaveBeenCalled();
expect(logger.logger.error).not.toHaveBeenCalledWith(
{ lookupName: 'golang.org/foo/something' },
'Unsupported dependency.'
);
expect(logger.logger.fatal).not.toHaveBeenCalled();
});
it('support ghe', async () => {
httpMock
Expand Down
5 changes: 5 additions & 0 deletions lib/datasource/go/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export async function getReleases({
const source = await getDatasource(lookupName);
let res = null;

if (!source) {
logger.warn({ lookupName }, 'Unsupported dependency.');
return null;
}

switch (source.datasource) {
case github.id: {
res = await github.getReleases(source);
Expand Down

0 comments on commit fd276e4

Please sign in to comment.