Skip to content

Commit 4f50e0f

Browse files
committed
Mock plugin spec cache in ConfigHoverTest
1 parent 3ad6106 commit 4f50e0f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/main/java/nextflow/lsp/services/config/ConfigService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ public boolean matchesFile(String uri) {
4848

4949
@Override
5050
public void initialize(LanguageServerConfiguration configuration) {
51+
initialize(configuration, new PluginSpecCache(configuration.pluginRegistryUrl()));
52+
}
53+
54+
public void initialize(LanguageServerConfiguration configuration, PluginSpecCache pluginSpecCache) {
5155
synchronized (this) {
52-
pluginSpecCache = new PluginSpecCache(configuration.pluginRegistryUrl());
56+
this.pluginSpecCache = pluginSpecCache;
5357
astCache.initialize(configuration, pluginSpecCache);
5458
}
5559
super.initialize(configuration);

src/test/groovy/nextflow/lsp/services/config/ConfigHoverTest.groovy

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
package nextflow.lsp.services.config
1818

19+
import nextflow.config.spec.SpecNode
20+
import nextflow.lsp.TestLanguageClient
21+
import nextflow.lsp.services.LanguageServerConfiguration
22+
import nextflow.lsp.spec.PluginSpec
23+
import nextflow.lsp.spec.PluginSpecCache
1924
import org.eclipse.lsp4j.Hover
2025
import org.eclipse.lsp4j.HoverParams
2126
import org.eclipse.lsp4j.Position
@@ -55,8 +60,18 @@ class ConfigHoverTest extends Specification {
5560

5661
def 'should get hover hint for a plugin config scope' () {
5762
given:
58-
def service = getConfigService()
5963
def uri = getUri('nextflow.config')
64+
def service = new ConfigService(workspaceRoot().toUri().toString())
65+
def configuration = LanguageServerConfiguration.defaults()
66+
def pluginSpecCache = Spy(new PluginSpecCache(configuration.pluginRegistryUrl()))
67+
pluginSpecCache.get('nf-prov', '1.6.0') >> new PluginSpec(
68+
[
69+
'prov': new SpecNode.Scope('The `prov` scope allows you to configure the `nf-prov` plugin.', [:])
70+
],
71+
[], [], []
72+
)
73+
service.connect(new TestLanguageClient())
74+
service.initialize(configuration, pluginSpecCache)
6075

6176
when:
6277
open(service, uri, '''\

0 commit comments

Comments
 (0)