mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Bug/fix peek definition integration test (#313)
* removed race condition in peek definition test * temporarily disabled peek definition tests * fixed peek definition connection race condition
This commit is contained in:
@@ -1008,7 +1008,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the fianl on-disconnect activities if the provided DisconnectParams represents the default
|
||||
/// Invokes the final on-disconnect activities if the provided DisconnectParams represents the default
|
||||
/// connection or is null - representing that all connections are being disconnected.
|
||||
/// </summary>
|
||||
private void InvokeOnDisconnectionActivities(ConnectionInfo connectionInfo)
|
||||
|
||||
@@ -700,111 +700,114 @@ GO";
|
||||
/// <summary>
|
||||
/// Get Definition for a object with no definition. Expect a error result
|
||||
/// </summary>
|
||||
// [Fact]
|
||||
// public async void GetDefinitionFromChildrenAndParents()
|
||||
// {
|
||||
// string queryString = "select * from master.sys.objects";
|
||||
[Fact]
|
||||
public async void GetDefinitionFromChildrenAndParents()
|
||||
{
|
||||
string queryString = "select * from master.sys.objects";
|
||||
|
||||
// // place the cursor on every token
|
||||
// place the cursor on every token
|
||||
|
||||
// //cursor on objects
|
||||
// TextDocumentPosition objectDocument = CreateTextDocPositionWithCursor(26, OwnerUri);
|
||||
//cursor on objects
|
||||
TextDocumentPosition objectDocument = CreateTextDocPositionWithCursor(26, OwnerUri);
|
||||
|
||||
// //cursor on sys
|
||||
// TextDocumentPosition sysDocument = CreateTextDocPositionWithCursor(22, OwnerUri);
|
||||
//cursor on sys
|
||||
TextDocumentPosition sysDocument = CreateTextDocPositionWithCursor(22, OwnerUri);
|
||||
|
||||
// //cursor on master
|
||||
// TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(15, OwnerUri);
|
||||
//cursor on master
|
||||
TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(15, OwnerUri);
|
||||
|
||||
// LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
// ScriptFile scriptFile = connectionResult.ScriptFile;
|
||||
// ConnectionInfo connInfo = connectionResult.ConnectionInfo;
|
||||
LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
ScriptFile scriptFile = connectionResult.ScriptFile;
|
||||
ConnectionInfo connInfo = connectionResult.ConnectionInfo;
|
||||
connInfo.RemoveAllConnections();
|
||||
var bindingQueue = new ConnectedBindingQueue();
|
||||
bindingQueue.AddConnectionContext(connInfo);
|
||||
scriptFile.Contents = queryString;
|
||||
|
||||
// var bindingQueue = new ConnectedBindingQueue();
|
||||
// bindingQueue.AddConnectionContext(connInfo);
|
||||
// scriptFile.Contents = queryString;
|
||||
var service = new LanguageService();
|
||||
service.BindingQueue = bindingQueue;
|
||||
await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo);
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// var service = new LanguageService();
|
||||
// service.BindingQueue = bindingQueue;
|
||||
// await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo);
|
||||
// Thread.Sleep(2000);
|
||||
ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
||||
scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo);
|
||||
service.ScriptParseInfoMap.Add(OwnerUri, scriptInfo);
|
||||
|
||||
// ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
||||
// scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo);
|
||||
// service.ScriptParseInfoMap.Add(OwnerUri, scriptInfo);
|
||||
// When I call the language service
|
||||
var objectResult = service.GetDefinition(objectDocument, scriptFile, connInfo);
|
||||
var sysResult = service.GetDefinition(sysDocument, scriptFile, connInfo);
|
||||
var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo);
|
||||
|
||||
// // When I call the language service
|
||||
// var objectResult = service.GetDefinition(objectDocument, scriptFile, connInfo);
|
||||
// var sysResult = service.GetDefinition(sysDocument, scriptFile, connInfo);
|
||||
// var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo);
|
||||
// Then I expect the results to be non-null
|
||||
Assert.NotNull(objectResult);
|
||||
Assert.NotNull(sysResult);
|
||||
Assert.NotNull(masterResult);
|
||||
|
||||
// // Then I expect the results to be non-null
|
||||
// Assert.NotNull(objectResult);
|
||||
// Assert.NotNull(sysResult);
|
||||
// Assert.NotNull(masterResult);
|
||||
// And I expect the all results to be the same
|
||||
Assert.True(CompareLocations(objectResult.Locations, sysResult.Locations));
|
||||
Assert.True(CompareLocations(objectResult.Locations, masterResult.Locations));
|
||||
|
||||
// // And I expect the all results to be the same
|
||||
// Assert.True(CompareLocations(objectResult.Locations, sysResult.Locations));
|
||||
// Assert.True(CompareLocations(objectResult.Locations, masterResult.Locations));
|
||||
Cleanup(objectResult.Locations);
|
||||
Cleanup(sysResult.Locations);
|
||||
Cleanup(masterResult.Locations);
|
||||
service.ScriptParseInfoMap.Remove(OwnerUri);
|
||||
connInfo.RemoveAllConnections();
|
||||
}
|
||||
|
||||
// Cleanup(objectResult.Locations);
|
||||
// Cleanup(sysResult.Locations);
|
||||
// Cleanup(masterResult.Locations);
|
||||
// service.ScriptParseInfoMap.Remove(OwnerUri);
|
||||
// }
|
||||
[Fact]
|
||||
public async void GetDefinitionFromProcedures()
|
||||
{
|
||||
|
||||
// [Fact]
|
||||
// public async void GetDefinitionFromProcedures()
|
||||
// {
|
||||
string queryString = "EXEC master.dbo.sp_MSrepl_startup";
|
||||
|
||||
// string queryString = "EXEC master.dbo.sp_MSrepl_startup";
|
||||
// place the cursor on every token
|
||||
|
||||
// // place the cursor on every token
|
||||
//cursor on objects
|
||||
TextDocumentPosition fnDocument = CreateTextDocPositionWithCursor(30, TestUri);
|
||||
|
||||
// //cursor on objects
|
||||
// TextDocumentPosition fnDocument = CreateTextDocPositionWithCursor(30, TestUri);
|
||||
//cursor on sys
|
||||
TextDocumentPosition dboDocument = CreateTextDocPositionWithCursor(14, TestUri);
|
||||
|
||||
// //cursor on sys
|
||||
// TextDocumentPosition dboDocument = CreateTextDocPositionWithCursor(14, TestUri);
|
||||
//cursor on master
|
||||
TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(10, TestUri);
|
||||
|
||||
// //cursor on master
|
||||
// TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(10, TestUri);
|
||||
LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
ScriptFile scriptFile = connectionResult.ScriptFile;
|
||||
ConnectionInfo connInfo = connectionResult.ConnectionInfo;
|
||||
connInfo.RemoveAllConnections();
|
||||
var bindingQueue = new ConnectedBindingQueue();
|
||||
bindingQueue.AddConnectionContext(connInfo);
|
||||
scriptFile.Contents = queryString;
|
||||
|
||||
// LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
// ScriptFile scriptFile = connectionResult.ScriptFile;
|
||||
// ConnectionInfo connInfo = connectionResult.ConnectionInfo;
|
||||
// var bindingQueue = new ConnectedBindingQueue();
|
||||
// bindingQueue.AddConnectionContext(connInfo);
|
||||
// scriptFile.Contents = queryString;
|
||||
var service = new LanguageService();
|
||||
service.BindingQueue = bindingQueue;
|
||||
await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo);
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// var service = new LanguageService();
|
||||
// service.BindingQueue = bindingQueue;
|
||||
// await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo);
|
||||
// Thread.Sleep(2000);
|
||||
ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
||||
scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo);
|
||||
service.ScriptParseInfoMap.Add(TestUri, scriptInfo);
|
||||
|
||||
// ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
||||
// scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo);
|
||||
// service.ScriptParseInfoMap.Add(TestUri, scriptInfo);
|
||||
// When I call the language service
|
||||
var fnResult = service.GetDefinition(fnDocument, scriptFile, connInfo);
|
||||
var sysResult = service.GetDefinition(dboDocument, scriptFile, connInfo);
|
||||
var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo);
|
||||
|
||||
// // When I call the language service
|
||||
// var fnResult = service.GetDefinition(fnDocument, scriptFile, connInfo);
|
||||
// var sysResult = service.GetDefinition(dboDocument, scriptFile, connInfo);
|
||||
// var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo);
|
||||
// Then I expect the results to be non-null
|
||||
Assert.NotNull(fnResult);
|
||||
Assert.NotNull(sysResult);
|
||||
Assert.NotNull(masterResult);
|
||||
|
||||
// // Then I expect the results to be non-null
|
||||
// Assert.NotNull(fnResult);
|
||||
// Assert.NotNull(sysResult);
|
||||
// Assert.NotNull(masterResult);
|
||||
// And I expect the all results to be the same
|
||||
Assert.True(CompareLocations(fnResult.Locations, sysResult.Locations));
|
||||
Assert.True(CompareLocations(fnResult.Locations, masterResult.Locations));
|
||||
|
||||
// // And I expect the all results to be the same
|
||||
// Assert.True(CompareLocations(fnResult.Locations, sysResult.Locations));
|
||||
// Assert.True(CompareLocations(fnResult.Locations, masterResult.Locations));
|
||||
|
||||
// Cleanup(fnResult.Locations);
|
||||
// Cleanup(sysResult.Locations);
|
||||
// Cleanup(masterResult.Locations);
|
||||
// service.ScriptParseInfoMap.Remove(TestUri);
|
||||
// }
|
||||
Cleanup(fnResult.Locations);
|
||||
Cleanup(sysResult.Locations);
|
||||
Cleanup(masterResult.Locations);
|
||||
service.ScriptParseInfoMap.Remove(TestUri);
|
||||
connInfo.RemoveAllConnections();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -863,4 +866,4 @@ GO";
|
||||
return textDocPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user