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

Commit c360269

Browse files
committed
Make PrepareTestData default to return no branches
Tests started throwing null reference exceptions when we stopped using an interface for BranchModel. This makes PrepareTestData default to return no branches.
1 parent dcbf8d1 commit c360269

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ static TestData PrepareTestData(
101101
api.GetRepository(Args.String, Args.String).Returns(Observable.Return(githubRepo));
102102
ms.ApiClient.Returns(api);
103103

104+
// Default to returning no branches
105+
ms.GetBranches(null).ReturnsForAnyArgs(Observable.Empty<BranchModel>());
106+
104107
// sets up the libgit2sharp repo and branch objects
105108
var l2repo = SetupLocalRepoMock(gitClient, gitService, remote, sourceBranchName, sourceBranchIsTracking);
106109

0 commit comments

Comments
 (0)