Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { | ||
IPCMessageReader, IPCMessageWriter, | ||
createConnection, IConnection, TextDocumentSyncKind, | ||
TextDocuments, TextDocument, Diagnostic, DiagnosticSeverity, | ||
InitializeParams, InitializeResult, TextDocumentPositionParams, | ||
CompletionItem, CompletionItemKind, RequestType | ||
} from 'vscode-languageserver'; | ||
import { xhr, XHRResponse, configure as configureHttpRequests, getErrorStatusDescription } from 'request-light'; | ||
import {getLanguageService} from '../src/languageservice/yamlLanguageService' | ||
import Strings = require( '../src/languageservice/utils/strings'); | ||
import URI from '../src/languageservice/utils/uri'; | ||
import * as URL from 'url'; | ||
import fs = require('fs'); | ||
import {JSONSchemaService} from '../src/languageservice/services/jsonSchemaService' | ||
import {schemaRequestService, workspaceContext} from './testHelper'; | ||
import { parse as parseYAML } from '../src/languageservice/parser/yamlParser'; | ||
import { YAMLDocument } from 'vscode-yaml-languageservice'; | ||
var assert = require('assert'); | ||
|
||
let languageService = getLanguageService(schemaRequestService, workspaceContext, [], null); | ||
|
||
let schemaService = new JSONSchemaService(schemaRequestService, workspaceContext); | ||
|
||
let uri = 'SchemaDoesNotExist'; | ||
let languageSettings = { | ||
schemas: [], | ||
validate: true, | ||
customTags: [] | ||
}; | ||
let fileMatch = ["*.yml", "*.yaml"]; | ||
languageSettings.schemas.push({ uri, fileMatch: fileMatch }); | ||
languageService.configure(languageSettings); | ||
|
||
// Defines a Mocha test suite to group tests of similar kind together | ||
suite("Validation Tests", () => { | ||
|
||
// Tests for validator | ||
describe('Validation', function() { | ||
|
||
function setup(content: string){ | ||
return TextDocument.create("file://~/Desktop/vscode-k8s/test.yaml", "yaml", 0, content); | ||
} | ||
|
||
function parseSetup(content: string){ | ||
let testTextDocument = setup(content); | ||
let yDoc = parseYAML(testTextDocument.getText(), languageSettings.customTags); | ||
return languageService.doValidation(testTextDocument, yDoc); | ||
} | ||
|
||
//Validating basic nodes | ||
describe('Test that validation throws error when schema is not found', function(){ | ||
|
||
it('Basic test', (done) => { | ||
let content = `testing: true`; | ||
let validator = parseSetup(content); | ||
validator.then(function(result){ | ||
assert.NotEqual(result.length, 0); | ||
}).then(done, done); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
}); |