Skip to content

Commit

Permalink
Merge pull request #331 from tagatac/fix-nan
Browse files Browse the repository at this point in the history
Convert NaN PR numbers to the empty string
  • Loading branch information
drazisil-codecov authored Aug 23, 2021
2 parents f6b7909 + 53ba78c commit 7ee76e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/helpers/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export async function uploadToCodecov(
*/
export function generateQuery(queryParams: IServiceParams): string {
checkValueType('pr', queryParams.pr, 'number')
if (queryParams.pr === 0) {
if (queryParams.pr === 0 || isNaN(Number(queryParams.pr))) {
queryParams.pr = ''
}
return Object.entries(queryParams)
Expand Down
19 changes: 19 additions & 0 deletions test/helpers/web.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,25 @@ describe('Web Helpers', () => {
)
})

it('NaN PR numbers are not propagated to the query', () => {
const queryParams: IServiceParams = {
branch: 'testBranch',
commit: 'commitSHA',
build: '4',
buildURL: 'https://ci-providor.local/job/xyz',
name: 'testName',
tag: 'tagV1',
slug: 'testOrg/testRepo',
service: 'testingCI',
flags: 'unit,uploader',
pr: NaN,
job: '6',
}
expect(generateQuery(queryParams)).toBe(
'branch=testBranch&commit=commitSHA&build=4&build_url=https://ci-providor.local/job/xyz&name=testName&tag=tagV1&slug=testOrg/testRepo&service=testingCI&flags=unit,uploader&pr=&job=6',
)
})

it('can populateBuildParams() from args', () => {
const result = populateBuildParams(
{ args: { flags: 'testFlag', tag: 'testTag' }, environment: {} },
Expand Down

0 comments on commit 7ee76e0

Please sign in to comment.