From 3006ae9acfe75609cd843c7017735f5584ec236b Mon Sep 17 00:00:00 2001 From: Elena Vilchik Date: Thu, 28 Jun 2018 10:15:14 +0200 Subject: Improve logic of node executable detection (#95) --- .../sonar/css/plugin/StylelintCommandProviderTest.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'sonar-css-plugin/src/test') diff --git a/sonar-css-plugin/src/test/java/org/sonar/css/plugin/StylelintCommandProviderTest.java b/sonar-css-plugin/src/test/java/org/sonar/css/plugin/StylelintCommandProviderTest.java index 3ae3250..0a44e18 100644 --- a/sonar-css-plugin/src/test/java/org/sonar/css/plugin/StylelintCommandProviderTest.java +++ b/sonar-css-plugin/src/test/java/org/sonar/css/plugin/StylelintCommandProviderTest.java @@ -57,20 +57,30 @@ public class StylelintCommandProviderTest { } @Test - public void test_node_executable() throws Exception { + public void test_node_executable_wo_settings() throws Exception { StylelintCommandProvider stylelintCommandProvider = new StylelintCommandProvider(); - MapSettings settings = new MapSettings(); assertThat(stylelintCommandProvider.nodeExecutable(settings.asConfig())).isEqualTo("node"); assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty(); + } + @Test + public void test_node_executable_custom() throws Exception { + StylelintCommandProvider stylelintCommandProvider = new StylelintCommandProvider(); + MapSettings settings = new MapSettings(); File customNode = temporaryFolder.newFile("custom-node.exe"); settings.setProperty(CssPlugin.NODE_EXECUTABLE, customNode.getAbsolutePath()); assertThat(stylelintCommandProvider.nodeExecutable(settings.asConfig())).isEqualTo(customNode.getAbsolutePath()); assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty(); + } + @Test + public void test_node_executable_custom_invalid() throws Exception { + StylelintCommandProvider stylelintCommandProvider = new StylelintCommandProvider(); + + MapSettings settings = new MapSettings(); settings.setProperty(CssPlugin.NODE_EXECUTABLE, "mynode"); assertThat(stylelintCommandProvider.nodeExecutable(settings.asConfig())).isEqualTo("node"); - assertThat(logTester.logs(LoggerLevel.WARN)).contains("Provided node executable file does not exist: mynode"); + assertThat(logTester.logs(LoggerLevel.WARN)).contains("Provided node executable file does not exist: mynode. Fallback to using 'node' from path."); } } -- cgit v1.2.3