Skip to content

Commit

Permalink
devonfw#451: fixed EditionSetCommandletTest
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille committed Jul 6, 2024
1 parent 124a804 commit 52daa78
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.devonfw.tools.ide.tool;

import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.AbstractIdeContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.io.FileAccess;
import com.devonfw.tools.ide.io.FileCopyMode;
Expand Down Expand Up @@ -291,7 +292,7 @@ private ToolInstallation createToolInstallation(Path rootDir, VersionIdentifier
if (newInstallation && (linkDir != rootDir)) {
assert (!linkDir.equals(rootDir));
this.context.getFileAccess().copy(toolVersionFile, linkDir, FileCopyMode.COPY_FILE_OVERRIDE);
if (this.context.getSystemInfo().isMac()) {
if (this.context.getSystemInfo().isMac() && !((AbstractIdeContext) this.context).isTest()) {
Path macApp = findMacApp(linkDir);
if (macApp != null) {
ProcessContext pc = this.context.newProcess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.devonfw.tools.ide.process.ProcessErrorHandling;
import com.devonfw.tools.ide.process.ProcessMode;
import com.devonfw.tools.ide.property.StringProperty;
import com.devonfw.tools.ide.url.model.folder.UrlEdition;
import com.devonfw.tools.ide.version.VersionIdentifier;

import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.devonfw.tools.ide.commandlet;

import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.context.IdeTestContext;
import com.devonfw.tools.ide.log.IdeLogLevel;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.util.List;

/** Integration test of {@link EditionSetCommandlet}. */
public class EditionSetCommandletTest extends AbstractIdeContextTest {
Expand All @@ -17,17 +15,18 @@ public class EditionSetCommandletTest extends AbstractIdeContextTest {
public void testEditionSetCommandletRun() {

// arrange
IdeContext context = newContext(PROJECT_BASIC);
IdeTestContext context = newContext(PROJECT_BASIC);
EditionSetCommandlet editionSet = context.getCommandletManager().getCommandlet(EditionSetCommandlet.class);
editionSet.tool.setValueAsString("mvn", context);
editionSet.edition.setValueAsString("setEdition", context);
editionSet.tool.setValueAsString("docker", context);
editionSet.edition.setValueAsString("rancher", context);
assertThat(context.getVariables().getToolEdition("docker")).isEqualTo("docker");

// act
editionSet.run();

// assert
List<String> logs = ((IdeTestContext) context).level(IdeLogLevel.WARNING).getMessages();
assertThat(logs).containsExactly("Edition setEdition seems to be invalid");
assertThat(context.getVariables().getToolEdition("docker")).isEqualTo("rancher");
assertLogMessage(context, IdeLogLevel.INFO, "DOCKER_EDITION=rancher has been set in SETTINGS@", true);
Path settingsIdeProperties = context.getSettingsPath().resolve("ide.properties");
assertThat(settingsIdeProperties).hasContent("""
#********************************************************************************
Expand All @@ -52,6 +51,6 @@ public void testEditionSetCommandletRun() {
TEST_ARGS9=settings9
TEST_ARGSb=${TEST_ARGS10} settingsb ${TEST_ARGSa} ${TEST_ARGSb}
TEST_ARGSc=${TEST_ARGSc} settingsc
MVN_EDITION=setEdition""");
DOCKER_EDITION=rancher""");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://desktop.docker.com/mac/main/arm64/Docker.dmg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://desktop.docker.com/mac/main/amd64/Docker.dmg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/rancher-desktop-linux-v1.14.2.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2d304d3fe0dbf5efe987c2d583feeb607ce9ef507753fcf0a6b1a6b9b2128d1e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop-1.14.2-mac.aarch64.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0ce7cf58fecbf4ea99541f51401f95ba70053b390b51ae98b16265d1a450a517
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop-1.14.2.x86_64.dmg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e764e335d1475f8bceb3fb6d1d1892b09d3c2bee3f34355ddab8a7e157c87452
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/rancher-sandbox/rancher-desktop/releases/download/v1.14.2/Rancher.Desktop.Setup.1.14.2.msi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
01f52b7a1ebcddeda01b6979ce3505b895fdcde2c5b57f18e4f8c4a593618f3f

0 comments on commit 52daa78

Please sign in to comment.