private void CloneEmptyRepositoryAndEnterRepo(string git, MsysgitResources resource) { var result = RunGit(git, String.Format(String.Format("clone {0}", RepositoryUrlWithCredentials), RepositoryName), WorkingDirectory); Assert.AreEqual(resource[MsysgitResources.Definition.CloneEmptyRepositoryOutput], result.Item1); Assert.AreEqual(resource[MsysgitResources.Definition.CloneEmptyRepositoryError], result.Item2); }
public void Initialize() { DeleteDirectory(WorkingDirectory); bool any_git_installed = false; List <string> not_found = new List <string>(); foreach (var version in GitVersions) { var git = String.Format(GitPath, version); if (File.Exists(git)) { var resource = new MsysgitResources(version); installedgits.Add(Tuple.Create(git, resource)); any_git_installed = true; } else { not_found.Add(git); } } if (!any_git_installed) { Assert.Fail(string.Format("Please ensure that you have at least one git installation in '{0}'.", string.Join("', '", not_found.Select(n => Path.GetFullPath(n))))); } EnsureCredentialHelperStore(installedgits.Last()); }
private void PushTag(string git, MsysgitResources resource) { RunGitOnRepo(git, "tag -a v1.4 -m \"my version 1.4\""); var result = RunGitOnRepo(git, "push --tags origin"); Assert.AreEqual(String.Format(resource[MsysgitResources.Definition.PushTagError], RepositoryUrlWithCredentials), result.Item2); }
private void PullBranch(string git, MsysgitResources resource) { var result = RunGitOnRepo(git, "pull origin TestBranch"); Assert.AreEqual("Already up-to-date.\r\n", result.Item1); Assert.AreEqual(String.Format(resource[MsysgitResources.Definition.PullBranchError], RepositoryUrlWithoutCredentials), result.Item2); }
private void PushBranch(string git, MsysgitResources resource) { RunGitOnRepo(git, "checkout -b \"TestBranch\""); var result = RunGitOnRepo(git, "push origin TestBranch"); Assert.AreEqual(String.Format(resource[MsysgitResources.Definition.PushBranchError], RepositoryUrlWithCredentials), result.Item2); }
public GitResult ErrorMustMatch(MsysgitResources.Definition resource, params object[] args) { var expected = string.Format(Resources[resource], args).Trim(); var actual = StdErr.Trim(); Assert.AreEqual(expected, actual, "Git operation StdErr mismatch"); return this; }
private void InitAndPullRepository(string git, MsysgitResources resource) { RunGitOnRepo(git, "init"); RunGitOnRepo(git, String.Format("remote add origin {0}", RepositoryUrlWithCredentials)); var result = RunGitOnRepo(git, "pull origin master"); Assert.AreEqual(String.Format(resource[MsysgitResources.Definition.PullRepositoryError], RepositoryUrlWithoutCredentials), result.Item2); }
private void PullRepository(string git, MsysgitResources resources) { DeleteDirectory(RepositoryDirectory); Directory.CreateDirectory(RepositoryDirectory); RunGit(git, "init"); RunGit(git, String.Format("remote add origin {0}", RepositoryUrlWithCredentials)); var result = RunGit(git, "pull origin master"); Assert.AreEqual(String.Format(resources[MsysgitResources.Definition.PullRepositoryError], RepositoryUrlWithoutCredentials), result.Item2); }
private void PushFiles(string git, MsysgitResources resource, bool success) { var res = RunGitOnRepo(git, "push origin master"); if (success) { Assert.AreEqual(string.Format(resource[MsysgitResources.Definition.PushFilesSuccessError], RepositoryUrlWithoutCredentials + ".git"), res.Item2); } else { Assert.AreEqual(string.Format(resource[MsysgitResources.Definition.PushFilesFailError], RepositoryUrlWithoutCredentials), res.Item2); } }
private void CreateAndPushFiles(string git, MsysgitResources resource) { CreateRandomFile(Path.Combine(RepositoryDirectory, "1.dat"), 10); CreateRandomFile(Path.Combine(RepositoryDirectory, "2.dat"), 1); Directory.CreateDirectory(Path.Combine(RepositoryDirectory, "SubDirectory")); CreateRandomFile(Path.Combine(RepositoryDirectory, "Subdirectory", "3.dat"), 20); CreateRandomFile(Path.Combine(RepositoryDirectory, "Subdirectory", "4.dat"), 15); RunGitOnRepo(git, "add ."); RunGitOnRepo(git, "commit -m \"Test Files Added\""); var result = RunGitOnRepo(git, "push origin master"); Assert.AreEqual(String.Format(resource[MsysgitResources.Definition.PushFilesSuccessError], RepositoryUrlWithCredentials), result.Item2); }
private void CloneRepoAnon(string git, MsysgitResources resource, bool success) { var result = RunGit(git, string.Format("clone {0}.git", RepositoryUrlWithoutCredentials), WorkingDirectory); if (success) { Assert.AreEqual(resource[MsysgitResources.Definition.CloneEmptyRepositoryOutput], result.Item1); Assert.AreEqual(resource[MsysgitResources.Definition.CloneEmptyRepositoryError], result.Item2); } else { Assert.AreEqual(resource[MsysgitResources.Definition.CloneEmptyRepositoryOutput], result.Item1); Assert.AreEqual(string.Format(resource[MsysgitResources.Definition.CloneRepositoryFailRequiresAuthError], Url.Substring(0, Url.Length - 1)), result.Item2); } }
public void RunGitTests() { bool has_any_test_run = false; List <string> gitpaths = new List <string>(); foreach (var version in GitVersions) { var git = String.Format(GitPath, version); if (!File.Exists(git)) { gitpaths.Add(git); continue; } var resources = new MsysgitResources(version); Directory.CreateDirectory(WorkingDirectory); try { Guid repo_id = CreateRepository(); CloneEmptyRepositoryAndEnterRepo(git, resources); CreateIdentity(git); PushFiles(git, resources); PushTag(git, resources); PushBranch(git, resources); CloneRepository(git, resources); PullRepository(git, resources); PullTag(git, resources); PullBranch(git, resources); DeleteRepository(repo_id); } finally { DeleteDirectory(WorkingDirectory); } has_any_test_run = true; } if (!has_any_test_run) { Assert.Fail(string.Format("Please ensure that you have at least one git installation in '{0}'.", string.Join("', '", gitpaths.Select(n => Path.GetFullPath(n))))); } }
private void PullTag(string git, MsysgitResources resource) { var result = RunGitOnRepo(git, "fetch"); Assert.AreEqual(String.Format(resource[MsysgitResources.Definition.PullTagError], RepositoryUrlWithoutCredentials), result.Item2); }