mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Allow empty query string text (#415)
* Allow empty query string text * Remove test that is no longer valid * Remove test that is no longer valid
This commit is contained in:
@@ -1050,7 +1050,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void ParseScript(string script, IBatchEventsHandler batchEventsHandler)
|
public void ParseScript(string script, IBatchEventsHandler batchEventsHandler)
|
||||||
{
|
{
|
||||||
Validate.IsNotNullOrEmptyString(nameof(script), script);
|
Validate.IsNotNull(nameof(script), script);
|
||||||
Validate.IsNotNull(nameof(batchEventsHandler), batchEventsHandler);
|
Validate.IsNotNull(nameof(batchEventsHandler), batchEventsHandler);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
|||||||
public Query(string queryText, ConnectionInfo connection, QueryExecutionSettings settings, IFileStreamFactory outputFactory)
|
public Query(string queryText, ConnectionInfo connection, QueryExecutionSettings settings, IFileStreamFactory outputFactory)
|
||||||
{
|
{
|
||||||
// Sanity check for input
|
// Sanity check for input
|
||||||
Validate.IsNotNullOrEmptyString(nameof(queryText), queryText);
|
Validate.IsNotNull(nameof(queryText), queryText);
|
||||||
Validate.IsNotNull(nameof(connection), connection);
|
Validate.IsNotNull(nameof(connection), connection);
|
||||||
Validate.IsNotNull(nameof(settings), settings);
|
Validate.IsNotNull(nameof(settings), settings);
|
||||||
Validate.IsNotNull(nameof(outputFactory), outputFactory);
|
Validate.IsNotNull(nameof(outputFactory), outputFactory);
|
||||||
|
|||||||
@@ -35,17 +35,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
|||||||
Assert.Throws<InvalidOperationException>(() => query.BatchSummaries);
|
Assert.Throws<InvalidOperationException>(() => query.BatchSummaries);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void QueryExecuteNoQueryText()
|
|
||||||
{
|
|
||||||
// If:
|
|
||||||
// ... I create a query that has a null query text
|
|
||||||
// Then:
|
|
||||||
// ... It should throw an exception
|
|
||||||
Assert.Throws<ArgumentException>(() =>
|
|
||||||
new Query(null, Common.CreateTestConnectionInfo(null, false), new QueryExecutionSettings(), MemoryFileSystem.GetFileStreamFactory()));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void QueryExecuteNoConnectionInfo()
|
public void QueryExecuteNoConnectionInfo()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -396,31 +396,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
|
|||||||
Assert.Equal(1, queryService.ActiveQueries.Count);
|
Assert.Equal(1, queryService.ActiveQueries.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task QueryExecuteMissingSelectionTest()
|
|
||||||
{
|
|
||||||
// Given:
|
|
||||||
// ... A workspace with a standard query is configured
|
|
||||||
var workspaceService = Common.GetPrimedWorkspaceService(string.Empty);
|
|
||||||
|
|
||||||
// If:
|
|
||||||
// ... I request to execute a query with a missing query string
|
|
||||||
var queryService = Common.GetPrimedExecutionService(null, true, false, workspaceService);
|
|
||||||
var queryParams = new ExecuteDocumentSelectionParams { OwnerUri = Constants.OwnerUri, QuerySelection = null};
|
|
||||||
|
|
||||||
var efv = new EventFlowValidator<ExecuteRequestResult>()
|
|
||||||
.AddStandardErrorValidation()
|
|
||||||
.Complete();
|
|
||||||
await queryService.HandleExecuteRequest(queryParams, efv.Object);
|
|
||||||
|
|
||||||
// Then:
|
|
||||||
// ... Am error should have been sent
|
|
||||||
efv.Validate();
|
|
||||||
|
|
||||||
// ... There should not be an active query
|
|
||||||
Assert.Empty(queryService.ActiveQueries);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task QueryExecuteInvalidQueryTest()
|
public async Task QueryExecuteInvalidQueryTest()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user