Dynamic completions and validations for stemcell names
This commit is contained in:
@@ -136,7 +136,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
t_stemcell_alias_def = f.yatomic("StemcellAlias")
|
||||
.parseWith(ValueParsers.NE_STRING);
|
||||
t_stemcell_alias_ref = f.yenumFromDynamicValues("StemcellAlias", (dc) -> astTypes.getDefinedNames(dc, t_stemcell_alias_def));
|
||||
|
||||
YType t_stemcell_name_ref = f.yenumFromDynamicValues("StemcellName", (dc) -> stemcellsProvider.getModel(dc).getStemcellNames());
|
||||
t_release_name_def = f.yatomic("ReleaseName")
|
||||
.parseWith(ValueParsers.NE_STRING);
|
||||
t_release_name_ref = f.yenumFromDynamicValues("ReleaseName", (dc) -> astTypes.getDefinedNames(dc, t_release_name_def));
|
||||
@@ -186,7 +186,7 @@ public class BoshDeploymentManifestSchema implements YamlSchema {
|
||||
YBeanType t_stemcell = f.ybean("Stemcell");
|
||||
addProp(t_stemcell, "alias", t_stemcell_alias_def).isRequired(true);
|
||||
addProp(t_stemcell, "version", t_ne_string).isRequired(true);
|
||||
addProp(t_stemcell, "name", t_ne_string);
|
||||
addProp(t_stemcell, "name", t_stemcell_name_ref);
|
||||
addProp(t_stemcell, "os", t_ne_string);
|
||||
t_stemcell.requireOneOf("name", "os");
|
||||
addProp(v2Schema, "stemcells", f.yseq(t_stemcell)).isRequired(true);
|
||||
|
||||
@@ -13,6 +13,7 @@ package org.springframework.ide.vscode.bosh;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.ide.vscode.languageserver.testharness.Editor.PLAIN_COMPLETION;
|
||||
import static org.springframework.ide.vscode.languageserver.testharness.TestAsserts.assertContains;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@@ -31,6 +32,8 @@ import org.springframework.ide.vscode.commons.yaml.reconcile.YamlSchemaProblems;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.Editor;
|
||||
import org.springframework.ide.vscode.languageserver.testharness.LanguageServerHarness;
|
||||
|
||||
import com.google.common.collect.ImmutableMultiset;
|
||||
|
||||
public class BoshEditorTest {
|
||||
|
||||
LanguageServerHarness harness;
|
||||
@@ -879,6 +882,39 @@ public class BoshEditorTest {
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void dynamicStemcellNamesFromDirector() throws Exception {
|
||||
StemcellsModel stemcellsModel = mock(StemcellsModel.class);
|
||||
when(stemcellsProvider.getModel(any())).thenReturn(stemcellsModel);
|
||||
when(stemcellsModel.getStemcellNames()).thenReturn(ImmutableMultiset.of(
|
||||
"bosh-vsphere-esxi-centos-7-go_agent",
|
||||
"bosh-vsphere-esxi-ubuntu-trusty-go_agent"
|
||||
));
|
||||
|
||||
//content assist
|
||||
Editor editor = harness.newEditor(
|
||||
"stemcells:\n" +
|
||||
"- alias: blah\n" +
|
||||
" name: <*>"
|
||||
);
|
||||
editor.assertContextualCompletions("<*>",
|
||||
"bosh-vsphere-esxi-centos-7-go_agent<*>",
|
||||
"bosh-vsphere-esxi-ubuntu-trusty-go_agent<*>"
|
||||
);
|
||||
|
||||
//reconcile
|
||||
editor = harness.newEditor(
|
||||
"stemcells:\n" +
|
||||
"- alias: good\n" +
|
||||
" name: bosh-vsphere-esxi-centos-7-go_agent\n" +
|
||||
"- alias: not-so-good\n" +
|
||||
" name: bogus<*>"
|
||||
);
|
||||
editor.ignoreProblem(YamlSchemaProblems.MISSING_PROPERTY);
|
||||
editor.assertProblems(
|
||||
"bogus|unknown 'StemcellName'. Valid values are: [bosh-vsphere-esxi-centos-7-go_agent, bosh-vsphere-esxi-ubuntu-trusty-go_agent]"
|
||||
);
|
||||
}
|
||||
|
||||
@Test public void contentAssistVMtype() throws Exception {
|
||||
Editor editor = harness.newEditor(
|
||||
"name: foo\n" +
|
||||
|
||||
Reference in New Issue
Block a user