Fix schema compare project test cleanup (#1746)

* cleanup .sqlproj in finally

* unique folder per test run

* fix path
This commit is contained in:
Kim Santiago
2022-11-04 10:33:25 -07:00
committed by GitHub
parent 1aae1d81f2
commit acf3e92e83
2 changed files with 68 additions and 41 deletions

View File

@@ -24,8 +24,13 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
{
private static string sqlProjectsFolder = Path.Combine("..", "..", "..", "SchemaCompare", "SqlProjects");
internal static void VerifyAndCleanup(string path)
internal static void VerifyAndCleanup(string? path)
{
if (path == null)
{
return;
}
// verify it was created...
Assert.True(File.Exists(path) || Directory.Exists(path), $"File or directory {path} was expected to exist but did not");
@@ -98,7 +103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.SchemaCompare
/// <returns>Full path to the .sqlproj</returns>
internal static string CreateSqlProj(string projectName)
{
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SchemaCompareTest", projectName);
string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SchemaCompareTest", $"{TestContext.CurrentContext?.Test?.Name}_{projectName}_{DateTime.Now.Ticks.ToString()}");
Directory.CreateDirectory(folderPath);
string sqlprojFilePath = Path.Combine(folderPath, projectName + ".sqlproj");
File.Copy(Path.Combine(sqlProjectsFolder, "emptyTemplate.sqlproj"), sqlprojFilePath);