Skip to content

Commit

Permalink
Verify that resolving a remote-tracking branch's remote can throw
Browse files Browse the repository at this point in the history
  • Loading branch information
jamill committed Sep 24, 2014
1 parent 1b820a5 commit 0e5bfbc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions LibGit2Sharp.Tests/BranchFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,33 @@ public void CanSetTrackedBranch()
}
}

[Fact]
public void SetTrackedBranchForUnreasolvableRemoteThrows()
{
const string testBranchName = "branchToSetUpstreamInfoFor";
const string trackedBranchName = "refs/remotes/origin/master";
var fetchRefSpecs = new string[] { "+refs/heads/notfound/*:refs/remotes/origin/notfound/*" };

string path = CloneStandardTestRepo();
using (var repo = new Repository(path))
{
// Modify the fetch spec so that the remote for the remote-tracking branch
// cannot be resolved.
Remote remote = repo.Network.Remotes["origin"];
Assert.NotNull(remote);
repo.Network.Remotes.Update(remote, r => r.FetchRefSpecs = fetchRefSpecs);

// Now attempt to update the tracked branch
Branch branch = repo.CreateBranch(testBranchName);
Assert.False(branch.IsTracking);

Branch trackedBranch = repo.Branches[trackedBranchName];

Assert.Throws<LibGit2SharpException>(() => repo.Branches.Update(branch,
b => b.TrackedBranch = trackedBranch.CanonicalName));
}
}

[Fact]
public void CanSetUpstreamBranch()
{
Expand Down

0 comments on commit 0e5bfbc

Please sign in to comment.