mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -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>
|
/// <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.
|
/// connection or is null - representing that all connections are being disconnected.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InvokeOnDisconnectionActivities(ConnectionInfo connectionInfo)
|
private void InvokeOnDisconnectionActivities(ConnectionInfo connectionInfo)
|
||||||
|
|||||||
@@ -700,111 +700,114 @@ GO";
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Definition for a object with no definition. Expect a error result
|
/// Get Definition for a object with no definition. Expect a error result
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// [Fact]
|
[Fact]
|
||||||
// public async void GetDefinitionFromChildrenAndParents()
|
public async void GetDefinitionFromChildrenAndParents()
|
||||||
// {
|
{
|
||||||
// string queryString = "select * from master.sys.objects";
|
string queryString = "select * from master.sys.objects";
|
||||||
|
|
||||||
// // place the cursor on every token
|
// place the cursor on every token
|
||||||
|
|
||||||
// //cursor on objects
|
//cursor on objects
|
||||||
// TextDocumentPosition objectDocument = CreateTextDocPositionWithCursor(26, OwnerUri);
|
TextDocumentPosition objectDocument = CreateTextDocPositionWithCursor(26, OwnerUri);
|
||||||
|
|
||||||
// //cursor on sys
|
//cursor on sys
|
||||||
// TextDocumentPosition sysDocument = CreateTextDocPositionWithCursor(22, OwnerUri);
|
TextDocumentPosition sysDocument = CreateTextDocPositionWithCursor(22, OwnerUri);
|
||||||
|
|
||||||
// //cursor on master
|
//cursor on master
|
||||||
// TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(15, OwnerUri);
|
TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(15, OwnerUri);
|
||||||
|
|
||||||
// LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo();
|
LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||||
// ScriptFile scriptFile = connectionResult.ScriptFile;
|
ScriptFile scriptFile = connectionResult.ScriptFile;
|
||||||
// ConnectionInfo connInfo = connectionResult.ConnectionInfo;
|
ConnectionInfo connInfo = connectionResult.ConnectionInfo;
|
||||||
|
connInfo.RemoveAllConnections();
|
||||||
|
var bindingQueue = new ConnectedBindingQueue();
|
||||||
|
bindingQueue.AddConnectionContext(connInfo);
|
||||||
|
scriptFile.Contents = queryString;
|
||||||
|
|
||||||
// var bindingQueue = new ConnectedBindingQueue();
|
var service = new LanguageService();
|
||||||
// bindingQueue.AddConnectionContext(connInfo);
|
service.BindingQueue = bindingQueue;
|
||||||
// scriptFile.Contents = queryString;
|
await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo);
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
|
||||||
// var service = new LanguageService();
|
ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
||||||
// service.BindingQueue = bindingQueue;
|
scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo);
|
||||||
// await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo);
|
service.ScriptParseInfoMap.Add(OwnerUri, scriptInfo);
|
||||||
// Thread.Sleep(2000);
|
|
||||||
|
|
||||||
// ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
// When I call the language service
|
||||||
// scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo);
|
var objectResult = service.GetDefinition(objectDocument, scriptFile, connInfo);
|
||||||
// service.ScriptParseInfoMap.Add(OwnerUri, scriptInfo);
|
var sysResult = service.GetDefinition(sysDocument, scriptFile, connInfo);
|
||||||
|
var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo);
|
||||||
|
|
||||||
// // When I call the language service
|
// Then I expect the results to be non-null
|
||||||
// var objectResult = service.GetDefinition(objectDocument, scriptFile, connInfo);
|
Assert.NotNull(objectResult);
|
||||||
// var sysResult = service.GetDefinition(sysDocument, scriptFile, connInfo);
|
Assert.NotNull(sysResult);
|
||||||
// var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo);
|
Assert.NotNull(masterResult);
|
||||||
|
|
||||||
// // Then I expect the results to be non-null
|
// And I expect the all results to be the same
|
||||||
// Assert.NotNull(objectResult);
|
Assert.True(CompareLocations(objectResult.Locations, sysResult.Locations));
|
||||||
// Assert.NotNull(sysResult);
|
Assert.True(CompareLocations(objectResult.Locations, masterResult.Locations));
|
||||||
// Assert.NotNull(masterResult);
|
|
||||||
|
|
||||||
// // And I expect the all results to be the same
|
Cleanup(objectResult.Locations);
|
||||||
// Assert.True(CompareLocations(objectResult.Locations, sysResult.Locations));
|
Cleanup(sysResult.Locations);
|
||||||
// Assert.True(CompareLocations(objectResult.Locations, masterResult.Locations));
|
Cleanup(masterResult.Locations);
|
||||||
|
service.ScriptParseInfoMap.Remove(OwnerUri);
|
||||||
|
connInfo.RemoveAllConnections();
|
||||||
|
}
|
||||||
|
|
||||||
// Cleanup(objectResult.Locations);
|
[Fact]
|
||||||
// Cleanup(sysResult.Locations);
|
public async void GetDefinitionFromProcedures()
|
||||||
// Cleanup(masterResult.Locations);
|
{
|
||||||
// service.ScriptParseInfoMap.Remove(OwnerUri);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [Fact]
|
string queryString = "EXEC master.dbo.sp_MSrepl_startup";
|
||||||
// public async void GetDefinitionFromProcedures()
|
|
||||||
// {
|
|
||||||
|
|
||||||
// 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
|
//cursor on sys
|
||||||
// TextDocumentPosition fnDocument = CreateTextDocPositionWithCursor(30, TestUri);
|
TextDocumentPosition dboDocument = CreateTextDocPositionWithCursor(14, TestUri);
|
||||||
|
|
||||||
// //cursor on sys
|
//cursor on master
|
||||||
// TextDocumentPosition dboDocument = CreateTextDocPositionWithCursor(14, TestUri);
|
TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(10, TestUri);
|
||||||
|
|
||||||
// //cursor on master
|
LiveConnectionHelper.TestConnectionResult connectionResult = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||||
// TextDocumentPosition masterDocument = CreateTextDocPositionWithCursor(10, TestUri);
|
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();
|
var service = new LanguageService();
|
||||||
// ScriptFile scriptFile = connectionResult.ScriptFile;
|
service.BindingQueue = bindingQueue;
|
||||||
// ConnectionInfo connInfo = connectionResult.ConnectionInfo;
|
await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo);
|
||||||
// var bindingQueue = new ConnectedBindingQueue();
|
Thread.Sleep(2000);
|
||||||
// bindingQueue.AddConnectionContext(connInfo);
|
|
||||||
// scriptFile.Contents = queryString;
|
|
||||||
|
|
||||||
// var service = new LanguageService();
|
ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
||||||
// service.BindingQueue = bindingQueue;
|
scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo);
|
||||||
// await service.UpdateLanguageServiceOnConnection(connectionResult.ConnectionInfo);
|
service.ScriptParseInfoMap.Add(TestUri, scriptInfo);
|
||||||
// Thread.Sleep(2000);
|
|
||||||
|
|
||||||
// ScriptParseInfo scriptInfo = new ScriptParseInfo { IsConnected = true };
|
// When I call the language service
|
||||||
// scriptInfo.ConnectionKey = bindingQueue.AddConnectionContext(connInfo);
|
var fnResult = service.GetDefinition(fnDocument, scriptFile, connInfo);
|
||||||
// service.ScriptParseInfoMap.Add(TestUri, scriptInfo);
|
var sysResult = service.GetDefinition(dboDocument, scriptFile, connInfo);
|
||||||
|
var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo);
|
||||||
|
|
||||||
// // When I call the language service
|
// Then I expect the results to be non-null
|
||||||
// var fnResult = service.GetDefinition(fnDocument, scriptFile, connInfo);
|
Assert.NotNull(fnResult);
|
||||||
// var sysResult = service.GetDefinition(dboDocument, scriptFile, connInfo);
|
Assert.NotNull(sysResult);
|
||||||
// var masterResult = service.GetDefinition(masterDocument, scriptFile, connInfo);
|
Assert.NotNull(masterResult);
|
||||||
|
|
||||||
// // Then I expect the results to be non-null
|
// And I expect the all results to be the same
|
||||||
// Assert.NotNull(fnResult);
|
Assert.True(CompareLocations(fnResult.Locations, sysResult.Locations));
|
||||||
// Assert.NotNull(sysResult);
|
Assert.True(CompareLocations(fnResult.Locations, masterResult.Locations));
|
||||||
// Assert.NotNull(masterResult);
|
|
||||||
|
|
||||||
// // And I expect the all results to be the same
|
Cleanup(fnResult.Locations);
|
||||||
// Assert.True(CompareLocations(fnResult.Locations, sysResult.Locations));
|
Cleanup(sysResult.Locations);
|
||||||
// Assert.True(CompareLocations(fnResult.Locations, masterResult.Locations));
|
Cleanup(masterResult.Locations);
|
||||||
|
service.ScriptParseInfoMap.Remove(TestUri);
|
||||||
// Cleanup(fnResult.Locations);
|
connInfo.RemoveAllConnections();
|
||||||
// Cleanup(sysResult.Locations);
|
}
|
||||||
// Cleanup(masterResult.Locations);
|
|
||||||
// service.ScriptParseInfoMap.Remove(TestUri);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user