public void Hardlink() { var root = new TestRoot { new TestDirectory("dir") { new TestFile("file"), new TestFile("executable") { IsExecutable = true }, new TestSymlink("symlink", "target") } }; root.Build(SourceDirectory); FileUtils.EnableWriteProtection(SourceDirectory); // Hard linking logic should work around write-protection by temporarily removing it try { new CloneDirectory(SourceDirectory, TargetDirectory) { UseHardlinks = true }.Run(); } finally { FileUtils.DisableWriteProtection(SourceDirectory); } root.Verify(TargetDirectory); FileUtils.AreHardlinked(Path.Combine(SourceDirectory, "dir", "file"), Path.Combine(TargetDirectory, "dir", "file")); FileUtils.AreHardlinked(Path.Combine(SourceDirectory, "dir", "executable"), Path.Combine(TargetDirectory, "dir", "executable")); }
private void TestDownload(TestRoot expected, params RetrievalMethod[] retrievalMethod) { var digest = new ManifestDigest(sha256New: "test123"); var testImplementation = new Implementation { ID = "test", ManifestDigest = digest }; testImplementation.RetrievalMethods.AddRange(retrievalMethod); StoreMock.Setup(x => x.GetPath(digest)).Returns(() => null); StoreMock.Setup(x => x.AddDirectory(It.Is <string>(path => expected.Verify(path)), digest, Handler)).Returns(""); BuildFetcher().Fetch(new[] { testImplementation }); }
public void OverwriteWithSymlink() { var root = new TestRoot { new TestSymlink("fileA", "target") }; root.Build(SourceDirectory); new TestRoot { new TestFile("fileB") }.Build(TargetDirectory); new CloneDirectory(SourceDirectory, TargetDirectory).Run(); root.Verify(TargetDirectory); }
public void OverwriteFile() { var root = new TestRoot { new TestFile("fileA") }; root.Build(SourceDirectory); new TestRoot { new TestFile("fileB") { LastWrite = new DateTime(2000, 2, 2), Contents = "wrong", IsExecutable = true } }.Build(TargetDirectory); new CloneDirectory(SourceDirectory, TargetDirectory).Run(); root.Verify(TargetDirectory); }
public void Copy() { var root = new TestRoot { new TestDirectory("dir") { new TestFile("file"), new TestFile("executable") { IsExecutable = true }, new TestSymlink("symlink", "target") } }; root.Build(SourceDirectory); new CloneDirectory(SourceDirectory, TargetDirectory).Run(); root.Verify(TargetDirectory); }
public void CopySuffix() { var root = new TestRoot { new TestDirectory("dir") { new TestFile("file"), new TestFile("executable") { IsExecutable = true }, new TestSymlink("symlink", "target") } }; root.Build(SourceDirectory); new CloneDirectory(SourceDirectory, TargetDirectory) { TargetSuffix = "suffix" }.Run(); root.Verify(Path.Combine(TargetDirectory, "suffix")); }