Example #1
0
        public void InstallFileWithMissingDependencyTest()
        {
            var def = new PackageDef();

            def.Name    = "Dummy2";
            def.OS      = "Windows,Linux";
            def.Version = SemanticVersion.Parse("1.0");
            def.AddFile("Dummy.txt");
            def.Dependencies.Add(new PackageDependency("Missing", VersionSpecifier.Parse("1.0")));
            DummyPackageGenerator.InstallDummyPackage("Missing");
            string pkgFile = DummyPackageGenerator.GeneratePackage(def);

            DummyPackageGenerator.UninstallDummyPackage("Missing");

            try
            {
                int    exitCode;
                string output = RunPackageCli("install Dummy2 -y", out exitCode);
                //Assert.AreNotEqual(0, exitCode, "Unexpected exit code");
                StringAssert.Contains("'Missing' with a version compatible with 1.0", output);
            }
            finally
            {
                File.Delete(pkgFile);
            }
        }
Example #2
0
        public void CyclicDependenciesTest()
        {
            DummyPackageGenerator.InstallDummyPackage(); // We need to have "Dummy" installed before we can create a package that depends on it.
            var depDef = new PackageDef();

            depDef.Name    = "Dependency";
            depDef.OS      = "Windows,Linux";
            depDef.Version = SemanticVersion.Parse("1.0");
            depDef.AddFile("Dependency.txt");
            depDef.Dependencies.Add(new PackageDependency("Dummy", VersionSpecifier.Parse("1.0")));
            string dep0File = DummyPackageGenerator.GeneratePackage(depDef);

            DummyPackageGenerator.UninstallDummyPackage();

            DummyPackageGenerator.InstallDummyPackage("Dependency");
            var dummyDef = new PackageDef();

            dummyDef.Name    = "Dummy";
            dummyDef.OS      = "Windows,Linux";
            dummyDef.Version = SemanticVersion.Parse("1.0");
            dummyDef.AddFile("Dummy.txt");
            dummyDef.Dependencies.Add(new PackageDependency("Dependency", VersionSpecifier.Parse("1.0")));
            string dummyFile = DummyPackageGenerator.GeneratePackage(dummyDef);

            DummyPackageGenerator.UninstallDummyPackage("Dependency");

            try
            {
                if (File.Exists("Dependency.txt"))
                {
                    File.Delete("Dependency.txt");
                }
                if (File.Exists("Dummy.txt"))
                {
                    File.Delete("Dummy.txt");
                }
                int    exitCode;
                string output = RunPackageCli("install Dummy -y", out exitCode);
                Assert.AreEqual(0, exitCode, "Unexpected exit code.\r\n" + output);
                StringAssert.Contains("Dummy", output);
                StringAssert.Contains("Dependency", output);
                Assert.IsTrue(File.Exists("Dependency.txt"));
                Assert.IsTrue(File.Exists("Dummy.txt"));
            }
            finally
            {
                PluginInstaller.Uninstall(dummyDef, Directory.GetCurrentDirectory());
                PluginInstaller.Uninstall(depDef, Directory.GetCurrentDirectory());
                File.Delete(dep0File);
                File.Delete(dummyFile);
            }
        }
Example #3
0
        public void UpgradeDependencyTest()
        {
            var dep0Def = new PackageDef();

            dep0Def.Name    = "Dependency";
            dep0Def.Version = SemanticVersion.Parse("0.1");
            dep0Def.AddFile("Dependency0.txt");
            string dep0File = DummyPackageGenerator.GeneratePackage(dep0Def);

            var dep1Def = new PackageDef();

            dep1Def.Name    = "Dependency";
            dep1Def.Version = SemanticVersion.Parse("1.0");
            dep1Def.AddFile("Dependency1.txt");
            string dep1File = DummyPackageGenerator.GeneratePackage(dep1Def);

            var dummyDef = new PackageDef();

            dummyDef.Name    = "Dummy";
            dummyDef.Version = SemanticVersion.Parse("1.0");
            dummyDef.AddFile("Dummy.txt");
            dummyDef.Dependencies.Add(new PackageDependency("Dependency", VersionSpecifier.Parse("1.0")));
            DummyPackageGenerator.InstallDummyPackage("Dependency");
            string dummyFile = DummyPackageGenerator.GeneratePackage(dummyDef);

            DummyPackageGenerator.UninstallDummyPackage("Dependency");


            try
            {
                int    exitCode;
                string output = RunPackageCli("install " + dep0File + " --force", out exitCode);
                Assert.AreEqual(0, exitCode, "Unexpected exit code");

                output = RunPackageCli("install Dummy -y", out exitCode);
                Assert.AreEqual(0, exitCode, "Unexpected exit code");
                //StringAssert.Contains("upgrading", output);
                Assert.IsTrue(File.Exists("Dependency1.txt"));
            }
            finally
            {
                PluginInstaller.Uninstall(dummyDef, Directory.GetCurrentDirectory());
                PluginInstaller.Uninstall(dep1Def, Directory.GetCurrentDirectory());
                File.Delete(dep0File);
                File.Delete(dep1File);
                File.Delete(dummyFile);
            }
        }
Example #4
0
        public void GitVersionDependency()
        {
            string inputFilename  = "Packages/GitVersionDependency/package.xml";
            string outputFilename = "GitversionDependency.TapPlugin";

            try
            {
                DummyPackageGenerator.InstallDummyPackage("DepName", new GitVersionCalulator(Directory.GetCurrentDirectory()).GetVersion().ToString());
                PackageDef pkg = PackageDefExt.FromInputXml(inputFilename, Directory.GetCurrentDirectory());
                pkg.CreatePackage(outputFilename);
                Assert.AreNotSame("$(GitVersion)", pkg.Dependencies.First().Version.ToString());
                VersionSpecifier versionSpecifier = new VersionSpecifier(pkg.Version, VersionMatchBehavior.Exact);

                Assert.AreEqual(pkg.Dependencies.FirstOrDefault(p => p.Name == "DepName").Version.ToString(), versionSpecifier.ToString());
            }
            finally
            {
                DummyPackageGenerator.UninstallDummyPackage("DepName");
                if (File.Exists(outputFilename))
                {
                    File.Delete(outputFilename);
                }
            }
        }