-
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.
This fixes a bug with MaxDepth that was also causing a panic because we expected the depth to be one more than it was returning. This fixes the function to now return the depth that is expected and in the case any more bugs exist in drawing the graph we handle that with an explicit check to ensure the padding is never less than 0.
- Loading branch information
1 parent
c79ab86
commit a186086
Showing
5 changed files
with
100 additions
and
12 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
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
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
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
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,73 @@ | ||
package git | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestMaxDepthZero(t *testing.T) { | ||
bnw := BranchNodeWrapper{ | ||
RootNodes: []*BranchNode{ | ||
{ | ||
Name: "master", | ||
}, | ||
}, | ||
} | ||
|
||
maxDepth := bnw.MaxDepth() | ||
if maxDepth != 0 { | ||
t.Error("maxDepth expected 0 but returned", maxDepth) | ||
} | ||
} | ||
|
||
func TestMaxDepthOne(t *testing.T) { | ||
bnw := BranchNodeWrapper{ | ||
RootNodes: []*BranchNode{ | ||
{ | ||
Name: "master", | ||
Downstream: []*BranchNode{ | ||
{ | ||
Name: "downstream-from-master", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
maxDepth := bnw.MaxDepth() | ||
if maxDepth != 1 { | ||
t.Error("maxDepth expected 1 but returned", maxDepth) | ||
} | ||
} | ||
|
||
func TestMaxDepthMany(t *testing.T) { | ||
bnw := BranchNodeWrapper{ | ||
RootNodes: []*BranchNode{ | ||
{ | ||
Name: "master", | ||
Downstream: []*BranchNode{ | ||
{ | ||
Name: "downstream-from-master", | ||
Downstream: []*BranchNode{ | ||
{ | ||
Name: "downstream-from-master-23", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "master2", | ||
Downstream: []*BranchNode{ | ||
{ | ||
Name: "downstream-from-master2", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
maxDepth := bnw.MaxDepth() | ||
if maxDepth != 2 { | ||
t.Error("maxDepth expected 2 but returned", maxDepth) | ||
} | ||
} |