Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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 });
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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"));
        }