Files
git-tfs/GitTfsTest/Integration/BootstrapTests.cs
T
Philippe Miossec cf20ce0ea6 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...
2014-04-20 00:10:44 +02:00

112 lines
3.8 KiB
C#

using System;
using Sep.Git.Tfs.Core.TfsInterop;
using Xunit;
using LibGit2Sharp;
namespace Sep.Git.Tfs.Test.Integration
{
public class BootstrapTests : IDisposable
{
IntegrationHelper h = new IntegrationHelper();
public BootstrapTests()
{
h.SetupFake(_ => { });
}
public void Dispose()
{
h.Dispose();
}
[Fact]
public void BootstrapWithNoRemotes()
{
h.SetupGitRepo("repo", g =>
{
g.Commit("A sample commit.");
});
h.RunIn("repo", "bootstrap");
h.AssertNoRef("repo", "tfs/default");
}
[Fact]
public void BootstrapWithARemoteAtHead()
{
string c1 = null;
h.SetupGitRepo("repo", g =>
{
c1 = g.Commit("A sample commit from TFS.\n\ngit-tfs-id: [http://server/tfs]$/MyProject;C1");
});
h.RunIn("repo", "bootstrap");
h.AssertRef("repo", "tfs/default", c1);
}
[Fact]
public void BootstrapWithARemoteAsAParentOfHead()
{
string c1 = null;
h.SetupGitRepo("repo", g =>
{
c1 = g.Commit("A sample commit from TFS.\n\ngit-tfs-id: [http://server/tfs]$/MyProject;C1");
g.Commit("Another sample commit.");
});
h.RunIn("repo", "bootstrap");
h.AssertRef("repo", "tfs/default", c1);
}
[Fact]
public void WhenUsingIOption_ThenAutoBootstrapingMaster()
{
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;
h.SetupGitRepo("repo", g =>
{
c1 = g.Commit("A sample commit from TFS.\n\ngit-tfs-id: [http://server/tfs]$/MyProject/trunk;C" + ChangesetIdToTrickFetch);
});
h.AssertNoRef("repo", "tfs/default");
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);
}
}
}
}