public static (string source, DirectoryInfo deployTargetDirectory, TempDirectory tempTargetDir) CopyTestData( ILogger logger) { string testDataPath = Path.Combine(VcsTestPathHelper.FindVcsRootPath(), "tests", "Milou.Deployer.Tests.Integration", "TestData", "AppDataTest"); string source = Path.Combine(testDataPath, "Source"); string target = Path.Combine(testDataPath, "Target"); var tempTargetDir = TempDirectory.CreateTempDirectory(); var deployTargetDirectory = tempTargetDir.Directory; deployTargetDirectory.Refresh(); RecursiveIO.RecursiveDelete(deployTargetDirectory, logger); deployTargetDirectory.EnsureExists(); var testTargetDirectory = new DirectoryInfo(target); RecursiveIO.RecursiveCopy(testTargetDirectory, deployTargetDirectory, logger, ImmutableArray <string> .Empty); deployTargetDirectory.Refresh(); var filesBefore = deployTargetDirectory.GetFiles(); foreach (var fileInfo in filesBefore) { logger.Debug("Existing file before deploy: {File}", fileInfo.Name); } Assert.Contains(filesBefore, file => file.Name.Equals("DeleteMe.txt", StringComparison.OrdinalIgnoreCase)); return(source, deployTargetDirectory, tempTargetDir); }
public async Task GetAllPackageVersionsDefaultConfig() { var nuGetPackageInstaller = new NuGetPackageInstaller(); string?configFile = Path.Combine(VcsTestPathHelper.TryFindVcsRootPath(), "tests", "Arbor.Tooler.Tests.Integration", "DefaultConfig", "nuget.config"); var packageVersions = await nuGetPackageInstaller.GetAllVersions(new NuGetPackageId("Newtonsoft.Json"), nugetConfig : configFile); packageVersions.Should().NotBeEmpty(); }
public async Task GetAllPackageVersions() { var nuGetPackageInstaller = new NuGetPackageInstaller(); Directory.SetCurrentDirectory(VcsTestPathHelper.TryFindVcsRootPath()); var packageVersions = await nuGetPackageInstaller.GetAllVersions(new NuGetPackageId("Newtonsoft.Json")); packageVersions.Should().NotBeEmpty(); }
public static async Task <TestConfiguration> CreateTestConfigurationAsync(CancellationToken cancellationToken) { const string projectName = "Milou.Deployer.Web.Tests.Integration"; string baseDirectoryPath = Path.Combine(Path.GetTempPath(), projectName + "-" + DateTime.UtcNow.Ticks); var baseDirectory = new DirectoryInfo(baseDirectoryPath); baseDirectory.Create(); DirectoryInfo targetAppRoot = baseDirectory.CreateSubdirectory("target"); DirectoryInfo nugetBaseDirectory = baseDirectory.CreateSubdirectory("nuget"); var packagesDirectory = nugetBaseDirectory.CreateSubdirectory("packages"); var nugetConfigFile = new FileInfo(Path.Combine(VcsTestPathHelper.GetRootDirectory(), "tests", "Milou.Deployer.Web.Tests.Integration", "TestData", "nuget.config")); if (!nugetConfigFile.Exists) { throw new InvalidOperationException($"The nuget config file {nugetConfigFile.FullName} does not exist"); } var packages = new DirectoryInfo(Path.Combine(VcsTestPathHelper.GetRootDirectory(), "tests", "Milou.Deployer.Web.Tests.Integration", "TestData", "packages")).GetFiles("*.nupkg"); string testNuGetConfig = Path.Combine(nugetBaseDirectory.FullName, "nuget.config"); string nugetConfigContent = await File.ReadAllTextAsync(nugetConfigFile.FullName, cancellationToken); string testConfigContent = nugetConfigContent.Replace("Packages", packagesDirectory.FullName); await File.WriteAllTextAsync(testNuGetConfig, testConfigContent, Encoding.UTF8, cancellationToken); foreach (var fileInfo in packages) { fileInfo.CopyTo(Path.Combine(packagesDirectory.FullName, fileInfo.Name), overwrite: true); } var testConfiguration = new TestConfiguration(baseDirectory, new FileInfo(testNuGetConfig), targetAppRoot); Console.WriteLine( $"Created test configuration {testConfiguration} with nuget config file content {Environment.NewLine}{nugetConfigContent}"); return(testConfiguration); }