Example #1
0
        public async Task CloneRepoAndCheckout(string path)
        {
            if (_pathToGit == null)
            {
                Assert.Ignore("no git implementation found!");
            }

            var folder = TestDirectoryHelper.UniqueTemporaryFolder();

            try
            {
                var gitDriver = new GitCmdDriver(_pathToGit, _logger, new Folder(_logger, folder), new Abstractions.Git.GitUsernamePasswordCredentials());
                Assert.DoesNotThrowAsync(() => gitDriver.Clone(new Uri(path)));
                Assert.IsTrue(Directory.Exists(Path.Combine(folder.FullName, ".git")), "Local git repo should exist in {0}", folder.FullName);

                // Checkout master branch
                Assert.DoesNotThrowAsync(() => gitDriver.Checkout("master"));
                var head = await gitDriver.GetCurrentHead();

                Assert.AreEqual(head, "master");

                // Checkout new branch
                Assert.DoesNotThrowAsync(() => gitDriver.CheckoutNewBranch("newBranch"));
                head = await gitDriver.GetCurrentHead();

                Assert.AreEqual("newBranch", head);
            }
            finally
            {
                TestDirectoryHelper.DeleteDirectory(folder);
            }
        }
Example #2
0
        public void Setup()
        {
            _logger    = new ConfigurableLogger();
            _pathTogit = TestDirectoryHelper.DiscoverPathToGit();
            if (_pathTogit == null)
            {
                Assert.Ignore("no git implementation found!");
            }

            // create a local repo to test against
            var folder    = TestDirectoryHelper.GenerateRandomSubFolder(TestContext.CurrentContext.WorkDirectory);
            var gitDriver = new GitCmdDriver(_pathTogit, _logger, new Folder(_logger, folder), new Abstractions.Git.GitUsernamePasswordCredentials());

            Assert.DoesNotThrowAsync(() => gitDriver.Clone(new Uri(_origin)));
            _repoPath = folder.FullName;
        }