mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-29 09:35:38 -05:00
fix schema comparing empty project showing more differences than expected (#1727)
This commit is contained in:
@@ -281,6 +281,41 @@ WITH VALUES
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the schema compare request comparing empty project to a database
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task SchemaCompareEmptyProjectToDatabase()
|
||||
{
|
||||
TestConnectionResult result = SchemaCompareTestUtils.GetLiveAutoCompleteTestObjects();
|
||||
SqlTestDb sourceDb = await SqlTestDb.CreateNewAsync(TestServerType.OnPrem, false, null, SourceScript, "SchemaCompareSource");
|
||||
|
||||
try
|
||||
{
|
||||
string targetProjectPath = SchemaCompareTestUtils.CreateSqlProj("TargetProject");
|
||||
string[] targetScripts = new string[0];
|
||||
|
||||
SchemaCompareEndpointInfo sourceInfo = CreateTestEndpoint(SchemaCompareEndpointType.Database, sourceDb.DatabaseName);
|
||||
SchemaCompareEndpointInfo targetInfo = CreateTestEndpoint(SchemaCompareEndpointType.Project, targetProjectPath, targetScripts);
|
||||
|
||||
var schemaCompareParams = new SchemaCompareParams
|
||||
{
|
||||
SourceEndpointInfo = sourceInfo,
|
||||
TargetEndpointInfo = targetInfo
|
||||
};
|
||||
|
||||
SchemaCompareOperation schemaCompareOperation = new(schemaCompareParams, result.ConnectionInfo, null);
|
||||
ValidateSchemaCompareWithExcludeIncludeResults(schemaCompareOperation, expectedDifferencesCount: 2);
|
||||
|
||||
// cleanup
|
||||
SchemaCompareTestUtils.VerifyAndCleanup(targetProjectPath);
|
||||
}
|
||||
finally
|
||||
{
|
||||
sourceDb.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify the schema compare request comparing a dacpac and a project
|
||||
/// </summary>
|
||||
@@ -1554,7 +1589,7 @@ WITH VALUES
|
||||
}
|
||||
}
|
||||
|
||||
private void ValidateSchemaCompareWithExcludeIncludeResults(SchemaCompareOperation schemaCompareOperation)
|
||||
private void ValidateSchemaCompareWithExcludeIncludeResults(SchemaCompareOperation schemaCompareOperation, int? expectedDifferencesCount = null)
|
||||
{
|
||||
schemaCompareOperation.Execute(TaskExecutionMode.Execute);
|
||||
|
||||
@@ -1563,6 +1598,11 @@ WITH VALUES
|
||||
Assert.NotNull(schemaCompareOperation.ComparisonResult.Differences);
|
||||
Assert.IsNull(schemaCompareOperation.ErrorMessage);
|
||||
|
||||
if (expectedDifferencesCount != null)
|
||||
{
|
||||
Assert.That(expectedDifferencesCount, Is.EqualTo(schemaCompareOperation.ComparisonResult.Differences.Count()), "The actual number of differences did not match the expected number");
|
||||
}
|
||||
|
||||
// create Diff Entry from Difference
|
||||
DiffEntry diff = SchemaCompareUtils.CreateDiffEntry(schemaCompareOperation.ComparisonResult.Differences.First(), null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user