Skip to content

Commit

Permalink
Tests: Remove the patching of the provenances' download time
Browse files Browse the repository at this point in the history
The `downloadTime` property has been removed from `Provenance` in a
preceeding change, so patching it does not make any sense anymore.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Apr 23, 2021
1 parent 56758e4 commit 11a7cf5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FileCounterScannerFunTest : StringSpec() {
val ortResult = scanner.scanOrtResult(analyzerResultFile, outputDir)
val result = yamlMapper.writeValueAsString(ortResult)

patchActualResult(result, patchDownloadTime = true, patchStartAndEndTime = true) shouldBe expectedResult
patchActualResult(result, patchStartAndEndTime = true) shouldBe expectedResult

outputDir.safeDeleteRecursively()
ScanResultsStorage.storage.stats.reset()
Expand Down
3 changes: 0 additions & 3 deletions test-utils/src/main/kotlin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ private val ENV_VAR_REGEX = Regex(
"(variables):.*?^(\\s{4}\\w+):",
setOf(RegexOption.DOT_MATCHES_ALL, RegexOption.MULTILINE)
)
private val DOWNLOAD_TIME_REGEX = Regex("(download_time): \".*\"")
private val START_AND_END_TIME_REGEX = Regex("((start|end)_time): \".*\"")
private val TIMESTAMP_REGEX = Regex("(timestamp): \".*\"")

Expand Down Expand Up @@ -75,7 +74,6 @@ fun patchExpectedResult(

fun patchActualResult(
result: String,
patchDownloadTime: Boolean = false,
patchStartAndEndTime: Boolean = false
): String {
fun String.replaceIf(condition: Boolean, regex: Regex, transform: (MatchResult) -> CharSequence) =
Expand All @@ -86,7 +84,6 @@ fun patchActualResult(
.replace(JAVA_VERSION_REGEX) { "${it.groupValues[1]}: \"${System.getProperty("java.version")}\"" }
.replace(ENV_VAR_REGEX) { "${it.groupValues[1]}: {}\n${it.groupValues[2]}:" }
.replace(TIMESTAMP_REGEX) { "${it.groupValues[1]}: \"${Instant.EPOCH}\"" }
.replaceIf(patchDownloadTime, DOWNLOAD_TIME_REGEX) { "${it.groupValues[1]}: \"${Instant.EPOCH}\"" }
.replaceIf(patchStartAndEndTime, START_AND_END_TIME_REGEX) { "${it.groupValues[1]}: \"${Instant.EPOCH}\"" }
}

Expand Down

0 comments on commit 11a7cf5

Please sign in to comment.