Skip to content

Commit

Permalink
fix [githubpipenv] service tests (#10658)
Browse files Browse the repository at this point in the history
* fix failing test 'Locked version of VCS dependency'

replaced tested package which is missing with another example

* Add regex validator for commit hash format

* fix vcs dependency test to use pipenv's pypiserver
  • Loading branch information
jNullj authored Nov 11, 2024
1 parent 6219c6d commit 4d203e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 4 additions & 6 deletions services/github/github-pipenv.tester.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Joi from 'joi'
import { ServiceTester } from '../tester.js'
import {
isCommitHash,
isVPlusDottedVersionAtLeastOne,
isVPlusDottedVersionNClausesWithOptionalSuffix,
} from '../test-validators.js'

// e.g. v19.3b0
const isBlackVersion = Joi.string().regex(/^v\d+(\.\d+)*(.*)?$/)
const isShortSha = Joi.string().regex(/[0-9a-f]{7}/)

export const t = new ServiceTester({
id: 'GithubPipenv',
Expand Down Expand Up @@ -82,10 +82,8 @@ t.create('Locked version of unknown dependency')
})

t.create('Locked version of VCS dependency')
.get(
'/locked/dependency-version/thorn-oss/perception/dev/videoalignment.json',
)
.get('/locked/dependency-version/pypa/pipenv/dev/pypiserver.json')
.expectBadge({
label: 'videoalignment',
message: isShortSha,
label: 'pypiserver',
message: isCommitHash,
})
3 changes: 3 additions & 0 deletions services/test-validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const isPhpVersionReduction = withRegex(
/^((>= \d+(\.\d+)?)|(\d+\.\d+(, \d+\.\d+)*)|(\d+\.\d+ - \d+\.\d+))(, HHVM)?$/,
)

const isCommitHash = withRegex(/^[a-f0-9]{7,40}$/)

const isStarRating = withRegex(
/^(?=.{5}$)(\u2605{0,5}[\u00BC\u00BD\u00BE]?\u2606{0,5})$/,
)
Expand Down Expand Up @@ -187,6 +189,7 @@ export {
isVPlusDottedVersionNClausesWithOptionalSuffixAndEpoch,
isComposerVersion,
isPhpVersionReduction,
isCommitHash,
isStarRating,
isMetric,
isMetricAllowNegative,
Expand Down

0 comments on commit 4d203e1

Please sign in to comment.