Fix plugin installation error if previously a plugin was installed with the same dependency which is still pending.

This commit is contained in:
Eduard Heimbuch
2020-08-25 12:41:07 +02:00
parent 61be5b154c
commit a36c0e2a16
3 changed files with 36 additions and 3 deletions

View File

@@ -37,7 +37,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import sonia.scm.NotFoundException;
@@ -90,6 +89,9 @@ class DefaultPluginManagerTest {
@Captor
private ArgumentCaptor<PluginEvent> eventCaptor;
@Captor
private ArgumentCaptor<PluginInstallationContext> contextCaptor;
private DefaultPluginManager manager;
@Mock
@@ -624,8 +626,31 @@ class DefaultPluginManagerTest {
assertThat(eventCaptor.getValue().getPlugin()).isEqualTo(review);
}
}
@Test
void contextShouldContainAvailablePluginsAndPendingInstallationPlugins() {
DefaultPluginManager manager = new DefaultPluginManager(
loader, center, installer, restarter, eventBus, null
);
AvailablePlugin jenkins = createAvailable("scm-jenkins-plugin");
AvailablePlugin webhook = createAvailable("scm-webhook-plugin");
when(jenkins.getDescriptor().getDependencies()).thenReturn(ImmutableSet.of("scm-el-plugin"));
when(webhook.getDescriptor().getDependencies()).thenReturn(ImmutableSet.of("scm-el-plugin"));
AvailablePlugin el = createAvailable("scm-el-plugin");
when(center.getAvailable()).thenReturn(ImmutableSet.of(jenkins, el, webhook));
manager.install("scm-jenkins-plugin", false);
manager.install("scm-webhook-plugin", false);
verify(installer, times(3)).install(contextCaptor.capture(), any());
PluginInstallationContext pluginInstallationContext = contextCaptor.getAllValues().get(2);
assertThat(pluginInstallationContext.find("scm-jenkins-plugin")).isPresent();
assertThat(pluginInstallationContext.find("scm-webhook-plugin")).isPresent();
assertThat(pluginInstallationContext.find("scm-el-plugin")).isPresent();
}
}
@Nested
class WithoutReadPermissions {