Skip to content

Commit

Permalink
Fix tests checkin handler
Browse files Browse the repository at this point in the history
  • Loading branch information
nquinquenel committed Sep 20, 2024
1 parent 9e40587 commit 310ea8a
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
package org.sonarlint.intellij.trigger;

import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.options.UnnamedConfigurable;
import com.intellij.openapi.progress.ProgressIndicator;
@@ -241,7 +242,11 @@ private ReturnResult showYesNoCancel(String resultStr) {
}

private void showChangedFilesTab(AnalysisResult analysisResult) {
runOnUiThread(project, () -> getService(project, SonarLintToolWindow.class).openReportTab(analysisResult));
if (ApplicationManager.getApplication().isUnitTestMode()) {
getService(project, SonarLintToolWindow.class).openReportTab(analysisResult);
} else {
runOnUiThread(project, () -> getService(project, SonarLintToolWindow.class).openReportTab(analysisResult));
}
}

private class MyRefreshableOnComponent implements RefreshableOnComponent, UnnamedConfigurable {
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ void testIssues() {
assertThat(result).isEqualTo(CheckinHandler.ReturnResult.CLOSE_WINDOW);
assertThat(messages).containsExactly("SonarLint analysis on 1 file found 1 issue");
ArgumentCaptor<AnalysisResult> analysisResultCaptor = ArgumentCaptor.forClass(AnalysisResult.class);
verify(toolWindow).openReportTab(analysisResultCaptor.capture());
verify(toolWindow, timeout(1000)).openReportTab(analysisResultCaptor.capture());
var analysisResult = analysisResultCaptor.getValue();
assertThat(analysisResult.getFindings().getIssuesPerFile()).containsEntry(file, Set.of(issue));
verify(analysisSubmitter, timeout(1000)).analyzeFilesPreCommit(Collections.singleton(file));
@@ -152,7 +152,7 @@ void testSecretsIssues() {
"\n" +
"SonarLint analysis found 1 secret. Committed secrets may lead to unauthorized system access.");
ArgumentCaptor<AnalysisResult> analysisResultCaptor = ArgumentCaptor.forClass(AnalysisResult.class);
verify(toolWindow).openReportTab(analysisResultCaptor.capture());
verify(toolWindow, timeout(1000)).openReportTab(analysisResultCaptor.capture());
var analysisResult = analysisResultCaptor.getValue();
assertThat(analysisResult.getFindings().getIssuesPerFile()).containsEntry(file, Set.of(issue));
verify(analysisSubmitter, timeout(1000)).analyzeFilesPreCommit(Collections.singleton(file));

0 comments on commit 310ea8a

Please sign in to comment.