Unit test for Autobootsrap when using -I option on a branch
Auto bootstap 'tfs/default' for first remote created Auto bootstap 'tfs/branch' for second remote created Extand IntegrationHelper to be able to create a more complexe test case...
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using Sep.Git.Tfs.Core.TfsInterop;
|
||||
using Xunit;
|
||||
using LibGit2Sharp;
|
||||
|
||||
namespace Sep.Git.Tfs.Test.Integration
|
||||
{
|
||||
@@ -73,5 +74,38 @@ namespace Sep.Git.Tfs.Test.Integration
|
||||
h.RunIn("repo", "fetch", "-I");
|
||||
h.AssertRef("repo", "tfs/default", c1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WhenUsingIOption_ThenAutoBootstrapingOneBrancheInAdditionToMaster()
|
||||
{
|
||||
int ChangesetIdToTrickFetch = 1;
|
||||
h.SetupFake(r =>
|
||||
{
|
||||
r.Changeset(ChangesetIdToTrickFetch, "UseLess! Just to have the same changeset Id that the commit already in repo (and fetch nothing)", DateTime.Parse("2012-01-01 12:12:12 -05:00"))
|
||||
.Change(TfsChangeType.Add, TfsItemType.Folder, "$/MyProject");
|
||||
});
|
||||
|
||||
string c1 = null;
|
||||
string c2 = null;
|
||||
h.SetupGitRepo("repo", g =>
|
||||
{
|
||||
c1 = g.Commit("A sample commit from TFS.\n\ngit-tfs-id: [http://server/tfs]$/MyProject/trunk;C" + ChangesetIdToTrickFetch);
|
||||
g.CreateBranch("branch");
|
||||
c2 = g.Commit("A sample commit from TFS.\n\ngit-tfs-id: [http://server/tfs]$/MyProject/branch;C" + ChangesetIdToTrickFetch);
|
||||
});
|
||||
|
||||
using (var repo = h.GetRepository("repo"))
|
||||
{
|
||||
repo.Checkout("master");
|
||||
h.AssertNoRef("repo", "tfs/default");
|
||||
h.RunIn("repo", "fetch", "-I");
|
||||
h.AssertRef("repo", "tfs/default", c1);
|
||||
|
||||
repo.Checkout("branch");
|
||||
h.AssertNoRef("repo", "tfs/branch");
|
||||
h.RunIn("repo", "fetch", "-I");
|
||||
h.AssertRef("repo", "tfs/branch", c2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,11 +72,18 @@ namespace Sep.Git.Tfs.Test.Integration
|
||||
|
||||
public void SetupGitRepo(string path, Action<RepoBuilder> buildIt)
|
||||
{
|
||||
var repoPath = LibGit2Sharp.Repository.Init(Path.Combine(Workdir, path));
|
||||
var fullPath = Path.Combine(Workdir, path);
|
||||
System.Diagnostics.Trace.WriteLine("Repository path:" + fullPath);
|
||||
var repoPath = LibGit2Sharp.Repository.Init(fullPath);
|
||||
using (var repo = new Repository(repoPath))
|
||||
buildIt(new RepoBuilder(repo));
|
||||
}
|
||||
|
||||
public Repository GetRepository(string path)
|
||||
{
|
||||
return new Repository(Path.Combine(Workdir, path));
|
||||
}
|
||||
|
||||
public class RepoBuilder
|
||||
{
|
||||
private Repository _repo;
|
||||
@@ -93,6 +100,16 @@ namespace Sep.Git.Tfs.Test.Integration
|
||||
var committer = new Signature("Test User", "test@example.com", new DateTimeOffset(DateTime.Now));
|
||||
return _repo.Commit(message, committer, committer).Id.Sha;
|
||||
}
|
||||
|
||||
public void CreateBranch(string branchName)
|
||||
{
|
||||
_repo.Checkout(_repo.CreateBranch(branchName));
|
||||
}
|
||||
|
||||
public void Checkout(string commitishName)
|
||||
{
|
||||
_repo.Checkout(commitishName);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user