mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Fix some integration tests (#1516)
* Fix integration test cases * More test fixes * Dacfx test fix * Make master default test db is none specified
This commit is contained in:
@@ -174,23 +174,29 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Connection
|
||||
/// Using connection details to build connection string
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task GetCurrentConnectionStringTestwithConnectionDetails()
|
||||
public async Task GetCurrentConnectionStringTestWithConnectionDetails()
|
||||
{
|
||||
// If we make a connection to a live database
|
||||
ConnectionService service = ConnectionService.Instance;
|
||||
var result = LiveConnectionHelper.InitLiveConnectionInfo();
|
||||
var resultConnectionDetails = result.ConnectionInfo.ConnectionDetails;
|
||||
var requestContext = new Mock<SqlTools.Hosting.Protocol.RequestContext<string>>();
|
||||
|
||||
requestContext.Setup(x => x.SendResult(It.Is<string>((connectionString) => connectionString.Contains(resultConnectionDetails.ToString()))))
|
||||
.Returns(Task.FromResult(new object()));
|
||||
var requestParams = new GetConnectionStringParams()
|
||||
var requestParams = new GetConnectionStringParams();
|
||||
requestParams.OwnerUri = null;
|
||||
requestParams.ConnectionDetails = new ConnectionDetails()
|
||||
{
|
||||
OwnerUri = null,
|
||||
ConnectionDetails = {ServerName = "testServer", DatabaseName = "testDatabase", UserName = "sa", Password = "password", ApplicationName = "TestApp"},
|
||||
IncludePassword = true,
|
||||
IncludeApplicationName = true
|
||||
ServerName = "testServer",
|
||||
DatabaseName = "testDatabase",
|
||||
UserName = "sa",
|
||||
Password = "[placeholder]",
|
||||
ApplicationName = "sqlops-connection-string"
|
||||
};
|
||||
requestParams.IncludePassword = true;
|
||||
requestParams.IncludeApplicationName = true;
|
||||
|
||||
// get the expected connection string from the connection details being passed to ConnectionService
|
||||
string expectedConnectionString = ConnectionService.CreateConnectionStringBuilder(requestParams.ConnectionDetails).ToString();
|
||||
|
||||
var requestContext = new Mock<SqlTools.Hosting.Protocol.RequestContext<string>>();
|
||||
requestContext.Setup(x => x.SendResult(It.Is<string>((connectionString) => connectionString.Contains(expectedConnectionString))))
|
||||
.Returns(Task.FromResult(new object()));
|
||||
|
||||
await service.HandleGetConnectionStringRequest(requestParams, requestContext.Object);
|
||||
requestContext.VerifyAll();
|
||||
|
||||
@@ -731,6 +731,7 @@ FROM MissingEdgeHubInputStream'";
|
||||
expectedResults.BlockOnPossibleDataLoss = new DeploymentOptionProperty<bool>(true);
|
||||
expectedResults.AllowIncompatiblePlatform = new DeploymentOptionProperty<bool>(true);
|
||||
expectedResults.DisableIndexesForDataPhase = new DeploymentOptionProperty<bool>(false);
|
||||
expectedResults.IgnoreTableOptions = new DeploymentOptionProperty<bool>(false);
|
||||
|
||||
var dacfxRequestContext = new Mock<RequestContext<DacFxOptionsResult>>();
|
||||
dacfxRequestContext.Setup((RequestContext<DacFxOptionsResult> x) => x.SendResult(It.Is<DacFxOptionsResult>((result) => ValidateOptions(expectedResults, result.DeploymentOptions) == true))).Returns(Task.FromResult(new object()));
|
||||
@@ -756,6 +757,7 @@ FROM MissingEdgeHubInputStream'";
|
||||
DeploymentOptions expectedResults = DeploymentOptions.GetDefaultPublishOptions();
|
||||
expectedResults.ExcludeObjectTypes = null;
|
||||
expectedResults.DisableIndexesForDataPhase = new DeploymentOptionProperty<bool>(false);
|
||||
expectedResults.IgnoreTableOptions = new DeploymentOptionProperty<bool>(false);
|
||||
|
||||
var dacfxRequestContext = new Mock<RequestContext<DacFxOptionsResult>>();
|
||||
dacfxRequestContext.Setup((RequestContext<DacFxOptionsResult> x) => x.SendResult(It.Is<DacFxOptionsResult>((result) => ValidateOptions(expectedResults, result.DeploymentOptions) == true))).Returns(Task.FromResult(new object()));
|
||||
@@ -779,6 +781,7 @@ FROM MissingEdgeHubInputStream'";
|
||||
public async Task ValidateGetDefaultPublishOptionsCallFromService()
|
||||
{
|
||||
DeploymentOptions expectedResults = DeploymentOptions.GetDefaultPublishOptions();
|
||||
expectedResults.IgnoreTableOptions = new DeploymentOptionProperty<bool>(false);
|
||||
|
||||
var dacfxRequestContext = new Mock<RequestContext<DacFxOptionsResult>>();
|
||||
dacfxRequestContext.Setup((RequestContext<DacFxOptionsResult> x) => x.SendResult(It.Is<DacFxOptionsResult>((result) => ValidateOptions(expectedResults, result.DeploymentOptions) == true))).Returns(Task.FromResult(new object()));
|
||||
@@ -855,10 +858,11 @@ Streaming query statement contains a reference to missing output stream 'Missing
|
||||
}
|
||||
else
|
||||
{
|
||||
// Verifying expected and actual deployment options properties are equal
|
||||
//Verifying expected and actual deployment options properties are equal
|
||||
Assert.True((defaultP == null && actualP == null)
|
||||
|| (defaultP == null && String.IsNullOrEmpty(actualP as string))
|
||||
|| defaultP.Equals(actualP)
|
||||
// check the type of the properties, the descriptions will not match when overriding defaults
|
||||
|| defaultP.GetType().Equals(actualP.GetType())
|
||||
, $"Actual Property from Service is not equal to default property for {v.Name}, Actual property: {actualP} and Default property: {defaultP}");
|
||||
|
||||
// Verifying expected and actual deployment options property values are equal
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility
|
||||
return new TestConnectionResult() { ConnectionInfo = connInfo, ScriptFile = scriptFile };
|
||||
}
|
||||
|
||||
public static async Task<TestConnectionResult> InitLiveConnectionInfoAsync(string databaseName = null, string ownerUri = null,
|
||||
public static async Task<TestConnectionResult> InitLiveConnectionInfoAsync(string databaseName = "master", string ownerUri = null,
|
||||
string connectionType = ServiceLayer.Connection.ConnectionType.Default, TestServerType serverType = TestServerType.OnPrem)
|
||||
{
|
||||
ScriptFile scriptFile = null;
|
||||
@@ -75,6 +75,10 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility
|
||||
scriptFile = TestServiceProvider.Instance.WorkspaceService.Workspace.GetFile(ownerUri);
|
||||
ownerUri = scriptFile.ClientUri;
|
||||
}
|
||||
if (string.IsNullOrEmpty(databaseName))
|
||||
{
|
||||
databaseName = "master";
|
||||
}
|
||||
ConnectParams connectParams = TestServiceProvider.Instance.ConnectionProfileService.GetConnectionParameters(serverType, databaseName);
|
||||
|
||||
var connectionService = GetLiveTestConnectionService();
|
||||
|
||||
Reference in New Issue
Block a user