* [GithubGoMod] Ignore comment after version (fixes #10079) * add unit tests for GithubGoModGoVersion.transform --------- Co-authored-by: chris48s <git@chris-shaw.dev>
This commit is contained in:
@@ -9,7 +9,7 @@ const queryParamSchema = Joi.object({
|
||||
filename: Joi.string(),
|
||||
}).required()
|
||||
|
||||
const goVersionRegExp = /^go (.+)$/m
|
||||
const goVersionRegExp = /^go ([^/\s]+)(\s*\/.+)?$/m
|
||||
|
||||
const filenameDescription =
|
||||
'The `filename` param can be used to specify the path to `go.mod`. By default, we look for `go.mod` in the repo root'
|
||||
|
||||
26
services/github/github-go-mod.spec.js
Normal file
26
services/github/github-go-mod.spec.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import { expect } from 'chai'
|
||||
import { test, given } from 'sazerac'
|
||||
import { InvalidResponse } from '../index.js'
|
||||
import GithubGoModGoVersion from './github-go-mod.service.js'
|
||||
|
||||
describe('GithubGoModGoVersion', function () {
|
||||
describe('valid cases', function () {
|
||||
test(GithubGoModGoVersion.transform, () => {
|
||||
given('go 1.18').expect({ go: '1.18' })
|
||||
given('go 1.18 // inline comment').expect({ go: '1.18' })
|
||||
given('go 1.18// inline comment').expect({ go: '1.18' })
|
||||
given('go 1.18 /* block comment */').expect({ go: '1.18' })
|
||||
given('go 1.18/* block comment */').expect({ go: '1.18' })
|
||||
given('go 1').expect({ go: '1' })
|
||||
given('go 1.2.3').expect({ go: '1.2.3' })
|
||||
given('go string').expect({ go: 'string' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('invalid cases', function () {
|
||||
expect(() => GithubGoModGoVersion.transform('')).to.throw(InvalidResponse)
|
||||
expect(() =>
|
||||
GithubGoModGoVersion.transform("doesn't start with go"),
|
||||
).to.throw(InvalidResponse)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user