Skip to content

Commit

Permalink
Merge pull request redhat-developer#46 from JPinkney/fork-issue-45
Browse files Browse the repository at this point in the history
Fixed jpinkney/vscode-k8s#45 and jpinkney/vscode-k8s#43 and added tes…
  • Loading branch information
JPinkney authored Jun 19, 2017
2 parents b830895 + 75ba037 commit ef9e0bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 8 additions & 4 deletions server/src/languageService/services/schemaValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,19 @@ export class YAMLSChemaValidator extends ASTVisitor {
case Kind.MAP :
let yamlMappingNodeList = [];
(<YamlMap> node).mappings.forEach(node => {
yamlMappingNodeList.push(this.generateChildren(node));
let gen = this.generateChildren(node);
yamlMappingNodeList.push(gen);
});
return yamlMappingNodeList;
return [].concat([], yamlMappingNodeList);
case Kind.SEQ :
let yamlSeqNodeList = [];
(<YAMLSequence> node).items.forEach(node => {
yamlSeqNodeList.push(this.generateChildren(node));
let gen = this.generateChildren(node);
gen.forEach(element => {
yamlSeqNodeList.push(element);
});
});
return yamlSeqNodeList;
return [].concat([], yamlSeqNodeList);
}
}

Expand Down
11 changes: 11 additions & 0 deletions server/test/schemaValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ suite("Validation Tests", () => {
assert.equal(result.items.length, 0);
}).then(done, done);
});

it('Advanced validation on full file with sequence nodes', (done) => {
let uri = "file://~/Desktop/vscode-k8s/test.yaml";
let content = `spec:\n containers:\n - name: front-end\n image: nginx\n ports:\n - containerPort: 80\n - name: rss-reader\n image: rss-php-nginx:v1\n ports:\n - containerPort: 88`;
let testTextDocument = TextDocument.create(uri, "yaml", 1, content);
let yDoc2 = yamlLoader(testTextDocument.getText(),{});
let validator = languageService.doValidation(testTextDocument, <YAMLDocument>yDoc2);
validator.then(function(result){
assert.equal(result.items.length, 0);
}).then(done, done);
});
});

describe('Validating types', function(){
Expand Down

0 comments on commit ef9e0bd

Please sign in to comment.