Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit dcbf8d1

Browse files
committed
Fix tests in PullRequestCreationViewModelTests
Not sure why branch in PullRequestCreationViewModel.Branches is coming up null in unit test. Need to investigate.
1 parent ec71110 commit dcbf8d1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/GitHub.App/ViewModels/GitHubPane/PullRequestCreationViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public PullRequestCreationViewModel(
8282
.Where(_ => TargetBranch != null)
8383
.Subscribe(x =>
8484
{
85-
if (!x.Any(t => t.Equals(TargetBranch)))
85+
// HACK: Why is `t` null?
86+
if (!x.Any(t => t != null && t.Equals(TargetBranch)))
8687
{
8788
TargetBranch = GitHubRepository.IsFork ? GitHubRepository.Parent.DefaultBranch : GitHubRepository.DefaultBranch;
8889
}

test/GitHub.App.UnitTests/ViewModels/GitHubPane/PullRequestCreationViewModelTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ static TestData PrepareTestData(
8181

8282
connection.HostAddress.Returns(HostAddress.Create("https://github.com"));
8383

84-
// this is the local repo instance that is available via TeamExplorerServiceHolder and friends
85-
var activeRepo = Substitute.For<LocalRepositoryModel>();
86-
activeRepo.LocalPath.Returns("");
87-
activeRepo.Name.Returns(repoName);
88-
activeRepo.CloneUrl.Returns(new UriString("http://github.com/" + sourceRepoOwner + "/" + repoName));
89-
activeRepo.Owner.Returns(sourceRepoOwner);
84+
var activeRepo = new LocalRepositoryModel
85+
{
86+
LocalPath = "",
87+
Name = repoName,
88+
CloneUrl = new UriString("http://github.com/" + sourceRepoOwner + "/" + repoName)
89+
};
9090

9191
Repository githubRepoParent = null;
9292
if (repoIsFork)

0 commit comments

Comments
 (0)