protected void SetupGit(NPath pathToSetupGitInto, string testName) { var installDetails = new GitInstaller.GitInstallDetails(pathToSetupGitInto, Environment); var state = installDetails.GetDefaults(); Environment.GitInstallationState = state; GitClient = new GitClient(Environment, ProcessManager, TaskManager.Token); if (installDetails.GitExecutablePath.FileExists() && installDetails.GitLfsExecutablePath.FileExists()) { return; } var key = installDetails.GitManifest.FileNameWithoutExtension + "_updatelastCheckTime"; Environment.UserSettings.Set(key, DateTimeOffset.Now); var localCache = TestLocation.Combine("Resources"); localCache.CopyFiles(pathToSetupGitInto, true); // skip checking for updates state.GitPackage = DugiteReleaseManifest.Load(installDetails.GitManifest, GitInstaller.GitInstallDetails.GitPackageFeed, Environment); var asset = state.GitPackage.DugitePackage; state.GitZipPath = installDetails.ZipPath.Combine(asset.Name); installDetails.GitInstallationPath.DeleteIfExists(); state.GitZipPath.EnsureParentDirectoryExists(); var gitExtractPath = TestBasePath.Combine("setup", "git_zip_extract_zip_paths").EnsureDirectoryExists(); var source = new UnzipTask(TaskManager.Token, state.GitZipPath, gitExtractPath, null, Environment.FileSystem) .RunSynchronously(); installDetails.GitInstallationPath.EnsureParentDirectoryExists(); source.Move(installDetails.GitInstallationPath); }
public async Task UnzipWorks() { var cacheContainer = Substitute.For <ICacheContainer>(); Environment = new IntegrationTestEnvironment(cacheContainer, TestBasePath, SolutionDirectory, new CreateEnvironmentOptions(TestBasePath)); InitializeTaskManager(); var expectedContent = @"Yup this is { good énough } ".Replace("\r\n", "\n"); var destinationPath = TestBasePath.Combine("unziptests").CreateDirectory(); var localCache = TestLocation.Combine("UnzipTestResources"); var archiveFilePath = localCache.Combine("testfile.zip"); var extractedPath = TestBasePath.Combine("zipextract").CreateDirectory(); var unzipTask = new UnzipTask(CancellationToken.None, archiveFilePath, extractedPath, ZipHelper.Instance, Environment.FileSystem); await unzipTask.StartAwait(); var expectedFile = extractedPath.Combine("embedded-git.json"); expectedFile.Parent.DirectoryExists().Should().BeTrue(); expectedFile.FileExists().Should().BeTrue(); var actualContent = expectedFile.ReadAllText(); actualContent.Should().Be(expectedContent); extractedPath = TestBasePath.Combine("tgzextract").CreateDirectory(); archiveFilePath = localCache.Combine("testfile.tgz"); unzipTask = new UnzipTask(CancellationToken.None, archiveFilePath, extractedPath, ZipHelper.Instance, Environment.FileSystem); await unzipTask.StartAwait(); expectedFile = extractedPath.Combine("embedded-git.json"); expectedFile.Parent.DirectoryExists().Should().BeTrue(); expectedFile.FileExists().Should().BeTrue(); expectedFile.ReadAllText().Should().Be(expectedContent); extractedPath = TestBasePath.Combine("targzextract").CreateDirectory(); archiveFilePath = localCache.Combine("testfile.tar.gz"); unzipTask = new UnzipTask(CancellationToken.None, archiveFilePath, extractedPath, ZipHelper.Instance, Environment.FileSystem); await unzipTask.StartAwait(); expectedFile = extractedPath.Combine("embedded-git.json"); expectedFile.Parent.DirectoryExists().Should().BeTrue(); expectedFile.FileExists().Should().BeTrue(); expectedFile.ReadAllText().Should().Be(expectedContent); }