From e45dba097a78f0d601d801b032e1d37146d7c7b4 Mon Sep 17 00:00:00 2001 From: Nikita Fedkin Date: Fri, 3 Dec 2021 17:06:54 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20readFile=20=D0=B2=20=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ru/pulsar/jenkins/library/utils/VersionParser.groovy | 2 +- .../groovy/ru/pulsar/jenkins/library/utils/TestUtils.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy b/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy index 9afc196..93c49da 100644 --- a/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy +++ b/src/ru/pulsar/jenkins/library/utils/VersionParser.groovy @@ -28,7 +28,7 @@ class VersionParser implements Serializable { return "" } - def configurationText = steps.readFile(filePath, 'UTF-8') + def configurationText = steps.readFile(filePath) return version(configurationText, regexp) } diff --git a/test/unit/groovy/ru/pulsar/jenkins/library/utils/TestUtils.java b/test/unit/groovy/ru/pulsar/jenkins/library/utils/TestUtils.java index 6d2e88b..92f5a4b 100644 --- a/test/unit/groovy/ru/pulsar/jenkins/library/utils/TestUtils.java +++ b/test/unit/groovy/ru/pulsar/jenkins/library/utils/TestUtils.java @@ -34,6 +34,11 @@ public class TestUtils { return FileUtils.readFileToString(new File(file), encoding); }); + when(steps.readFile(anyString())).thenAnswer(invocation -> { + String file = invocation.getArgument(0); + return FileUtils.readFileToString(new File(file), StandardCharsets.UTF_8); + }); + when(steps.fileExists(anyString())).thenAnswer(invocation -> { String file = invocation.getArgument(0); return new File(file).exists();