mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-26 18:29:47 +01:00
Improve plugin center error feedback and cache invalidation (#2147)
The plugin center cache was not invalidated when the proxy configuration was changed in the global settings. This caused stale and inconsistent state to be displayed to the user while there was no feedback that something was wrong.
This commit is contained in:
committed by
GitHub
parent
ec83de3600
commit
7b933c6821
@@ -33,8 +33,8 @@ import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.cache.CacheManager;
|
||||
import sonia.scm.cache.MapCacheManager;
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
import sonia.scm.config.ScmConfigurationChangedEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -92,7 +92,7 @@ class PluginCenterTest {
|
||||
Set<PluginSet> pluginSets = new HashSet<>();
|
||||
|
||||
PluginCenterResult first = new PluginCenterResult(plugins, pluginSets);
|
||||
when(loader.load(anyString())).thenReturn(first, new PluginCenterResult(Collections.emptySet(), Collections.emptySet()));
|
||||
when(loader.load(anyString())).thenReturn(first, new PluginCenterResult());
|
||||
|
||||
assertThat(pluginCenter.getAvailablePlugins()).isSameAs(plugins);
|
||||
assertThat(pluginCenter.getAvailablePlugins()).isSameAs(plugins);
|
||||
@@ -101,12 +101,12 @@ class PluginCenterTest {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void shouldClearCache() {
|
||||
void shouldClearCacheOnPluginCenterLogin() {
|
||||
Set<AvailablePlugin> plugins = new HashSet<>();
|
||||
Set<PluginSet> pluginSets = new HashSet<>();
|
||||
|
||||
PluginCenterResult first = new PluginCenterResult(plugins, pluginSets);
|
||||
when(loader.load(anyString())).thenReturn(first, new PluginCenterResult(Collections.emptySet(), Collections.emptySet()));
|
||||
when(loader.load(anyString())).thenReturn(first, new PluginCenterResult());
|
||||
|
||||
assertThat(pluginCenter.getAvailablePlugins()).isSameAs(plugins);
|
||||
assertThat(pluginCenter.getAvailablePluginSets()).isSameAs(pluginSets);
|
||||
@@ -115,6 +115,22 @@ class PluginCenterTest {
|
||||
assertThat(pluginCenter.getAvailablePluginSets()).isNotSameAs(pluginSets);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void shouldClearCacheOnConfigChange() {
|
||||
Set<AvailablePlugin> plugins = new HashSet<>();
|
||||
Set<PluginSet> pluginSets = new HashSet<>();
|
||||
|
||||
PluginCenterResult first = new PluginCenterResult(plugins, pluginSets);
|
||||
when(loader.load(anyString())).thenReturn(first, new PluginCenterResult());
|
||||
|
||||
assertThat(pluginCenter.getAvailablePlugins()).isSameAs(plugins);
|
||||
assertThat(pluginCenter.getAvailablePluginSets()).isSameAs(pluginSets);
|
||||
pluginCenter.handle(new ScmConfigurationChangedEvent(null));
|
||||
assertThat(pluginCenter.getAvailablePlugins()).isNotSameAs(plugins);
|
||||
assertThat(pluginCenter.getAvailablePluginSets()).isNotSameAs(pluginSets);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldLoadOnRefresh() {
|
||||
Set<AvailablePlugin> plugins = new HashSet<>();
|
||||
|
||||
Reference in New Issue
Block a user