-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show local status by default in
stack status
command (#159)
- Loading branch information
1 parent
0906f7e
commit e53ba99
Showing
10 changed files
with
385 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
199 changes: 119 additions & 80 deletions
199
src/Stack.Tests/Commands/Stack/StackStatusCommandHandlerTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using FluentAssertions; | ||
using Stack.Git; | ||
|
||
namespace Stack.Tests.Git; | ||
|
||
public class GitBranchStatusParserTests | ||
{ | ||
[Fact] | ||
public void WhenBranchIsCurrentBranch_ReturnsCorrectStatus() | ||
{ | ||
// Arrange | ||
var branchStatus = "* main 1234567 [origin/main] Some message"; | ||
|
||
// Act | ||
var result = GitBranchStatusParser.Parse(branchStatus); | ||
|
||
// Assert | ||
result.Should().Be(new GitBranchStatus("main", "origin/main", true, true, 0, 0, new Commit("1234567", "Some message"))); | ||
} | ||
|
||
[Fact] | ||
public void WhenBranchIsAheadAndBehindItsRemoteTrackingBranch_ReturnsCorrectStatus() | ||
{ | ||
// Arrange | ||
var branchStatus = " main 1234567 [origin/main: ahead 1, behind 2] Some message"; | ||
|
||
// Act | ||
var result = GitBranchStatusParser.Parse(branchStatus); | ||
|
||
// Assert | ||
result.Should().Be(new GitBranchStatus("main", "origin/main", true, false, 1, 2, new Commit("1234567", "Some message"))); | ||
} | ||
|
||
[Fact] | ||
public void WhenBranchIsAheadOfItsRemoteTrackingBranch_ReturnsCorrectStatus() | ||
{ | ||
// Arrange | ||
var branchStatus = " main 1234567 [origin/main: ahead 1] Some message"; | ||
|
||
// Act | ||
var result = GitBranchStatusParser.Parse(branchStatus); | ||
|
||
// Assert | ||
result.Should().Be(new GitBranchStatus("main", "origin/main", true, false, 1, 0, new Commit("1234567", "Some message"))); | ||
} | ||
|
||
[Fact] | ||
public void WhenBranchIsBehindItsRemoteTrackingBranch_ReturnsCorrectStatus() | ||
{ | ||
// Arrange | ||
var branchStatus = " main 1234567 [origin/main: behind 2] Some message"; | ||
|
||
// Act | ||
var result = GitBranchStatusParser.Parse(branchStatus); | ||
|
||
// Assert | ||
result.Should().Be(new GitBranchStatus("main", "origin/main", true, false, 0, 2, new Commit("1234567", "Some message"))); | ||
} | ||
|
||
[Fact] | ||
public void WhenBranchIsNotTracked_ReturnsCorrectStatus() | ||
{ | ||
// Arrange | ||
var branchStatus = " main 1234567 Some message"; | ||
|
||
// Act | ||
var result = GitBranchStatusParser.Parse(branchStatus); | ||
|
||
// Assert | ||
result.Should().Be(new GitBranchStatus("main", null, false, false, 0, 0, new Commit("1234567", "Some message"))); | ||
} | ||
|
||
[Fact] | ||
public void WhenRemoteTrackingBranchIsGone_ReturnsCorrectStatus() | ||
{ | ||
// Arrange | ||
var branchStatus = " main 1234567 [origin/main: gone] Some message"; | ||
|
||
// Act | ||
var result = GitBranchStatusParser.Parse(branchStatus); | ||
|
||
// Assert | ||
result.Should().Be(new GitBranchStatus("main", "origin/main", false, false, 0, 0, new Commit("1234567", "Some message"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.