Files
renovate/lib/workers
Michael Kriese 7aedcb24d2 test(workers/lookup): cover untested branches under lookup/ (#45930)
* test(workers/lookup): cover the remaining generateUpdate branches

Adds a unit spec for `generateUpdate()` exercising the branches that the
surrounding lookup tests never reached: a release carrying `checksumUrl`,
`downloadUrl` and `newDigest`, a versioning api whose `getNewValue`
throws, and an update with no current version.

With those covered, the last istanbul ignores in the file can go, so
`generate.ts` now reports full statement and branch coverage with
nothing suppressed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(workers/lookup): cover two untested lookup branches

Adds tests for two paths flagged by the `TODO: add test #40625` markers
that no existing test reached:

- `filterInternalChecks()` with a release that has no `releaseTimestamp`
  while `minimumReleaseAgeBehaviour` is unset. The existing tests only
  cover `timestamp-required` and `timestamp-optional`, so the release is
  now checked to be accepted without being reported under either.
- `lookupUpdates()` when no current version can be resolved but a
  `lockedVersion` is set, which must return without marking the
  dependency `invalid-value`.

The ignore comments are left in place, so these branches stay excluded
from the coverage report; each test instead asserts an outcome that only
holds on the intended path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(workers/lookup): cover error paths in bucket, current and rollback

Adds unit specs for three exported helpers whose guard clauses no test
reached: `getBucket()` when the versioning api cannot determine a major
or a minor, `getCurrentVersion()` when the current value is not a string,
and `getRollbackUpdate()` when the versioning api lacks
`isLessThanRange()`, when `isLessThanRange()` throws, and when there is
nothing older to roll back to.

The ignore comments on those branches are left in place, so the coverage
report is unchanged; each test asserts the return value that is only
produced by the guard it targets.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(workers/lookup): cover filter and rollback guards

Covers three more guards that no test reached: `filterVersions()` with
no current version, and `filterByMaxMajorIncrement()` when the versioning
api cannot determine the current major or a release's major. Adds a
`lookupUpdates()` test for the case where rollbacks are enabled but
nothing older exists to roll back to, which warns instead of updating.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(workers/lookup): cover the vulnerability alert range strategy fallback

A vulnerability alert configured with `rangeStrategy=update-lockfile` but
no locked version falls back to `bump`, which no test covered. The new
test asserts the range is widened and the update is marked as a bump,
which only happens once the fallback has been applied.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs(workers/lookup): explain the remaining coverage ignores

Each ignore left under `lookup/` now records why the branch it hides is
not reached, instead of pointing at a TODO with no detail. No ignore is
added or removed, and the coverage report is unchanged.

The explanation goes above the hint rather than after it: a hint only
applies to the statement on the line immediately below, so trailing
comment lines silently stop it from suppressing anything.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(workers/lookup): cover three more unreached lookup branches

Covers the guards behind three of the remaining ignore hints:

- `getRollbackUpdate()` when the release it falls back to carries an
  empty version, so there is nothing to roll back to after all
- `filterVersions()` coercing a release version that the configured
  versioning accepts but semver cannot parse, which happens once
  `allowedVersions` falls back to semver range syntax
- `lookupUpdates()` when the datasource rejects every candidate release
  during postprocessing, leaving a bucket with no release to update to

The ignore comments stay in place, so the coverage report is unchanged;
each test asserts an outcome that only holds on the intended path.

Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io>

* docs(workers/lookup): correct the ignore reasons this branch disproves

Three of the reasons added alongside the previous batch of tests claimed
their branch was unreachable, which the tests in this branch disprove:
`getRollbackUpdate()` can pop a versionless release, `filterVersions()`
does coerce a version semver cannot parse, and `filterInternalChecks()`
yields no release when a datasource rejects every candidate. Each now
describes what actually reaches it.

Also sharpens two of the reasons that still stand. The `getBucket()`
else contradicts the `isVersion()` filter every release has already
passed, so it reads as unreachable rather than untested; and a lookup
whose releases are all unversioned tags never reaches the empty-version
block, because a configured digest routes it to the digest-only path
first.

No ignore is added or removed, and the coverage report is unchanged.

Co-Authored-By: Claude Opus 5 <michael.kriese+claude-code@mend.io>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 5 <michael.kriese+claude-code@mend.io>
2026-09-14 12:29:39 +00:00
..