fix schema comparing empty project showing more differences than expected (#1727)

This commit is contained in:
Kim Santiago
2022-10-21 14:04:31 -07:00
committed by GitHub
parent 99dbbd5036
commit 6f198e9e5a
5 changed files with 85 additions and 4 deletions

View File

@@ -22,6 +22,8 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
{
internal static class SchemaCompareTestUtils
{
private static string sqlProjectsFolder = Path.Combine("..", "..", "..", "SchemaCompare", "SqlProjects");
internal static void VerifyAndCleanup(string path)
{
// verify it was created...
@@ -61,12 +63,17 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
return extractParams.PackageFilePath;
}
/// <summary>
/// Creates an SDK-style .sqlproj from the database
/// </summary>
/// <param name="testdb">Database to create the sql project from</param>
/// <param name="projectName">Name of the project</param>
/// <returns>Full path to the project folder</returns>
internal static string CreateProject(SqlTestDb testdb, string projectName)
{
var result = GetLiveAutoCompleteTestObjects();
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SchemaCompareTest", projectName);
Directory.CreateDirectory(folderPath);
File.Create(Path.Combine(folderPath, projectName + ".sqlproj")).Close();
string sqlprojFilePath = CreateSqlProj(projectName);
string folderPath = Path.GetDirectoryName(sqlprojFilePath);
var extractParams = new ExtractParams
{
@@ -84,6 +91,21 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
return folderPath;
}
/// <summary>
/// Creates an empty SDK-style .sqlproj
/// </summary>
/// <param name="projectName">name for the .sqlproj</param>
/// <returns>Full path to the .sqlproj</returns>
internal static string CreateSqlProj(string projectName)
{
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SchemaCompareTest", projectName);
Directory.CreateDirectory(folderPath);
string sqlprojFilePath = Path.Combine(folderPath, projectName + ".sqlproj");
File.Copy(Path.Combine(sqlProjectsFolder, "emptyTemplate.sqlproj"), sqlprojFilePath);
return sqlprojFilePath;
}
internal static string[] GetProjectScripts(string projectPath)
{
return Directory.GetFiles(projectPath, "*.sql", SearchOption.AllDirectories);