From 5894698d000bf39886a72328d7f69880ec375ac6 Mon Sep 17 00:00:00 2001 From: Thevakumar-Luheerathan Date: Thu, 7 Dec 2023 09:43:54 -0800 Subject: [PATCH] Fix CLI test failures on windows --- .../src/test/java/io/ballerina/cli/cmd/PullCommandTest.java | 4 ++-- .../src/test/java/io/ballerina/cli/cmd/PushCommandTest.java | 5 +++-- .../windows/run-project-with-dump-raw-graphs.txt | 4 ++-- .../command-outputs/windows/test-project-with-dump-graph.txt | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/PullCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/PullCommandTest.java index 9b5b0f992c8b..5e00924e4438 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/PullCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/PullCommandTest.java @@ -147,7 +147,7 @@ public void testPullCommandWithHelp() throws IOException { } @Test(description = "Pull a package from custom remote repository") - public void testPullCustom() throws SettingsTomlException { + public void testPullCustom() throws SettingsTomlException, IOException { Path customrRepoPath = Paths.get("src", "test", "resources", "test-resources", "custom-repo", "repositories", "repo-push-pull"); @@ -160,7 +160,7 @@ public void testPullCustom() throws SettingsTomlException { try (MockedStatic repoUtils = Mockito.mockStatic(RepoUtils.class, Mockito.CALLS_REAL_METHODS)) { repoUtils.when(RepoUtils::createAndGetHomeReposPath).thenReturn(mockBallerinaHome); repoUtils.when(RepoUtils::readSettings).thenReturn(readMockSettings(settingsTomlPath, - customrRepoPath.toAbsolutePath().toString())); + customrRepoPath.toAbsolutePath().toString().replace("\\", "/"))); pullCommand.execute(); } Path pulledCacheDir = mockBallerinaHome.resolve("repositories").resolve("repo-push-pull") diff --git a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/PushCommandTest.java b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/PushCommandTest.java index 2e19ff3bf5b5..5b482b2b0a1f 100644 --- a/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/PushCommandTest.java +++ b/cli/ballerina-cli/src/test/java/io/ballerina/cli/cmd/PushCommandTest.java @@ -101,12 +101,13 @@ public void testPushPackageCustom() throws IOException, SettingsTomlException { new CommandLine(pushCommand).parse(args); try (MockedStatic repoUtils = Mockito.mockStatic(RepoUtils.class, Mockito.CALLS_REAL_METHODS)) { repoUtils.when(RepoUtils::readSettings).thenReturn(readSettings(testResources.resolve("custom-repo") - .resolve("Settings.toml"), mockRepo.toAbsolutePath().toString())); + .resolve("Settings.toml"), mockRepo.toAbsolutePath().toString() + .replace("\\", "/"))); pushCommand.execute(); } String buildLog = readOutput(true); String actual = buildLog.replaceAll("\r", ""); - Assert.assertEquals(actual, expected); + Assert.assertEquals(actual.replace("\\", "/"), expected); String artifact = packageName + "-" + version + BALA_EXTENSION; String pomFile = packageName + "-" + version + POM_EXTENSION; String pushPullPath = mockRepo.resolve(org).resolve(packageName).resolve(version).toAbsolutePath().toString(); diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/run-project-with-dump-raw-graphs.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/run-project-with-dump-raw-graphs.txt index 6b621acd24ba..9f942c9acf47 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/run-project-with-dump-raw-graphs.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/run-project-with-dump-raw-graphs.txt @@ -7,7 +7,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; @@ -51,7 +51,7 @@ digraph "Initial" { node [shape=record] "foo/package_a" [label="<0.1.0> foo/package_a:0.1.0"]; "foo/package_b" [label="<0.1.0> foo/package_b:0.1.0"]; - "foo/package_c" [label="<0.1.0> foo/package_c:0.1.0"]; + "foo/package_c" [unresolved="true",color="grey",label="<0.1.0> foo/package_c:0.1.0"]; // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; diff --git a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/test-project-with-dump-graph.txt b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/test-project-with-dump-graph.txt index f1518124fded..e1e1e57fb8cf 100644 --- a/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/test-project-with-dump-graph.txt +++ b/cli/ballerina-cli/src/test/resources/test-resources/command-outputs/windows/test-project-with-dump-graph.txt @@ -12,4 +12,5 @@ digraph "foo/package_a:0.1.0" { // Edges "foo/package_a":"0.1.0" -> "foo/package_b":"0.1.0"; "foo/package_b":"0.1.0" -> "foo/package_c":"0.1.0"; -} \ No newline at end of file +} + No tests found \ No newline at end of file