Skip to content

Commit

Permalink
test(osv): Rename a constant for consistency
Browse files Browse the repository at this point in the history
While at it, move it next to the other constants.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Jan 20, 2025
1 parent 36ab555 commit daf9e81
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clients/osv/src/funTest/kotlin/OsvServiceWrapperFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ private val VULNERABILITY_FOR_PACKAGE_BY_INVALID_COMMIT_REQUEST = Vulnerabilitie
commit = "6879efc2c1596d11a6a6ad296f80063b558d5e0c"
)

private val EMPTY_JSON_OBJECT = JsonObject(emptyMap())

private fun Vulnerability.patchIgnorableFields() =
copy(
modified = Instant.EPOCH,
databaseSpecific = emptyJsonObject.takeIf { databaseSpecific != null },
databaseSpecific = EMPTY_JSON_OBJECT.takeIf { databaseSpecific != null },
affected = affected.mapTo(mutableSetOf()) { affected ->
affected.copy(ecosystemSpecific = emptyJsonObject.takeIf { affected.ecosystemSpecific != null })
affected.copy(ecosystemSpecific = EMPTY_JSON_OBJECT.takeIf { affected.ecosystemSpecific != null })
}
)

Expand All @@ -63,8 +65,6 @@ private fun Vulnerability.normalizeUrls(): Vulnerability {
return copy(references = references)
}

private val emptyJsonObject = JsonObject(emptyMap())

private fun List<Vulnerability>.patch() = map { it.patch() }
private fun Vulnerability.patch() = patchIgnorableFields().normalizeUrls()

Expand Down

0 comments on commit daf9e81

Please sign in to comment.