Add test for task toplevel property reconcile
Note: The test is still failing
This commit is contained in:
@@ -99,7 +99,7 @@ public class Editor {
|
||||
this.harness = harness;
|
||||
this.languageId = languageId;
|
||||
EditorState state = new EditorState(contents);
|
||||
this.document = harness.openDocument(harness.createWorkingCopy(state.documentContents));
|
||||
this.document = harness.openDocument(harness.createWorkingCopy(state.documentContents, languageId));
|
||||
this.selectionStart = state.selectionStart;
|
||||
this.selectionEnd = state.selectionEnd;
|
||||
this.ignoredTypes = new HashSet<>();
|
||||
|
||||
@@ -81,23 +81,23 @@ public class LanguageServerHarness {
|
||||
this(factory, LanguageIds.PLAINTEXT);
|
||||
}
|
||||
|
||||
public synchronized TextDocumentInfo getOrReadFile(File file) throws Exception {
|
||||
public synchronized TextDocumentInfo getOrReadFile(File file, String languageId) throws Exception {
|
||||
String uri = file.toURI().toString();
|
||||
TextDocumentInfo d = documents.get(uri);
|
||||
if (d==null) {
|
||||
documents.put(uri, d = readFile(file));
|
||||
documents.put(uri, d = readFile(file, languageId));
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
public TextDocumentInfo readFile(File file) throws Exception {
|
||||
public TextDocumentInfo readFile(File file, String languageId) throws Exception {
|
||||
byte[] encoded = Files.readAllBytes(file.toPath());
|
||||
String content = new String(encoded, getEncoding());
|
||||
TextDocumentItem document = new TextDocumentItem();
|
||||
document.setText(content);
|
||||
document.setUri(file.toURI().toString());
|
||||
document.setVersion(getFirstVersion());
|
||||
document.setLanguageId(getDefaultLanguageId());
|
||||
document.setLanguageId(languageId);
|
||||
return new TextDocumentInfo(document);
|
||||
}
|
||||
|
||||
@@ -188,8 +188,8 @@ public class LanguageServerHarness {
|
||||
return documentInfo;
|
||||
}
|
||||
|
||||
public TextDocumentInfo openDocument(File file) throws Exception {
|
||||
return openDocument(getOrReadFile(file));
|
||||
public TextDocumentInfo openDocument(File file, String languageId) throws Exception {
|
||||
return openDocument(getOrReadFile(file, languageId));
|
||||
}
|
||||
|
||||
public synchronized TextDocumentInfo changeDocument(String uri, int start, int end, String replaceText) {
|
||||
@@ -330,9 +330,13 @@ public class LanguageServerHarness {
|
||||
return new Editor(this, contents, getDefaultLanguageId());
|
||||
}
|
||||
|
||||
public synchronized TextDocumentInfo createWorkingCopy(String contents) throws Exception {
|
||||
public Editor newEditor(String languageId, String contents) throws Exception {
|
||||
return new Editor(this, contents, languageId);
|
||||
}
|
||||
|
||||
public synchronized TextDocumentInfo createWorkingCopy(String contents, String languageId) throws Exception {
|
||||
TextDocumentItem doc = new TextDocumentItem();
|
||||
doc.setLanguageId(getDefaultLanguageId());
|
||||
doc.setLanguageId(languageId);
|
||||
doc.setText(contents);
|
||||
doc.setUri(createTempUri());
|
||||
doc.setVersion(getFirstVersion());
|
||||
|
||||
@@ -1454,6 +1454,31 @@ public class ConcourseEditorTest {
|
||||
|
||||
}
|
||||
|
||||
@Test public void reconcileTaskFileToplevelProperties() throws Exception {
|
||||
Editor editor = harness.newEditor(LanguageIds.CONCOURSE_TASK,
|
||||
"platform: a-platform\n" +
|
||||
"image_resource:\n" +
|
||||
" type: docker-image\n" +
|
||||
" source:\n" +
|
||||
" bogus-source-prop: bad\n" +
|
||||
" repository: ruby\n" +
|
||||
" tag: '2.1'\n" +
|
||||
"image: some-image\n" +
|
||||
"inputs:\n" +
|
||||
"- path: path/to/input\n" +
|
||||
"outputs:\n" +
|
||||
"- path: path/to/output\n" +
|
||||
"run:\n" +
|
||||
" path: my-app/scripts/test"
|
||||
);
|
||||
editor.assertProblems(
|
||||
"a-platform|blah",
|
||||
"bogus-source-prop|Unkown property",
|
||||
"path: path/to/input|'name' is required",
|
||||
"path: path/to/output|'name' is required"
|
||||
);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void assertContextualCompletions(String conText, String textBefore, String... textAfter) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user