Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1110: Fixed ide status fails with IllegalStateException when being offline #1125

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cli/awstest

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public void run() {
logSettingsLegacyStatus();
logMigrationStatus();
}
checkForUpdate();
}

private void checkForUpdate() {
if (!this.context.isOnline()) {
this.context.warning("Check for newer version of IDEasy is skipped due to no network connectivity.");
return;
}
new IdeasyCommandlet(this.context, null).checkIfUpdateIsAvailable();
logSystemInfo();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.junit.jupiter.api.Test;

import com.devonfw.tools.ide.cli.CliArguments;
import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;

Expand All @@ -17,13 +16,30 @@ public class StatusCommandletTest extends AbstractIdeContextTest {
public void testStatusOutsideOfHome() {
//arrange
IdeTestContext context = new IdeTestContext();
CliArguments args = new CliArguments("status");
args.next();
StatusCommandlet status = context.getCommandletManager().getCommandlet(StatusCommandlet.class);

//act
context.run(args);
status.run();

//assert
assertThat(context).logAtWarning().hasMessageContaining("You are not inside an IDE project: ");
}

/**
* Tests the output if {@link StatusCommandlet} is run without internet connection.
*/
@Test
public void testStatusWhenOffline() {

// arrange
IdeTestContext context = new IdeTestContext();
context.setOnline(false);
StatusCommandlet status = context.getCommandletManager().getCommandlet(StatusCommandlet.class);

// act
status.run();

// assert
assertThat(context).logAtWarning().hasMessage("Check for newer version of IDEasy is skipped due to no network connectivity.");
}
}