Skip to content

Commit

Permalink
Merge pull request #139 from vmarkovtsev/master
Browse files Browse the repository at this point in the history
Fix #138
  • Loading branch information
vmarkovtsev authored Dec 14, 2018
2 parents 7b7c6f3 + 0f4827b commit 3530ffb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion leaves/burndown.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ func (analyser *BurndownAnalysis) Finalize() interface{} {
globalHistory, lastDay := analyser.groupSparseHistory(analyser.globalHistory, -1)
fileHistories := map[string]DenseHistory{}
for key, history := range analyser.fileHistories {
fileHistories[key], _ = analyser.groupSparseHistory(history, lastDay)
if len(history) > 0 {
fileHistories[key], _ = analyser.groupSparseHistory(history, lastDay)
}
}
peopleHistories := make([]DenseHistory, analyser.PeopleNumber)
for i, history := range analyser.peopleHistories {
Expand Down
15 changes: 15 additions & 0 deletions leaves/burndown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1170,3 +1170,18 @@ func TestBurndownDeserialize(t *testing.T) {
assert.Equal(t, result.granularity, 30)
assert.Equal(t, result.sampling, 30)
}

func TestBurndownEmptyFileHistory(t *testing.T) {
burndown := &BurndownAnalysis{
Sampling: 30,
Granularity: 30,
globalHistory: sparseHistory{0: map[int]int64{0: 10}},
fileHistories: map[string]sparseHistory{"test.go": {}},
}
res := burndown.Finalize().(BurndownResult)
assert.Len(t, res.GlobalHistory, 1)
assert.Len(t, res.FileHistories, 0)
assert.NotNil(t, res.FileHistories)
assert.Len(t, res.PeopleHistories, 0)
assert.NotNil(t, res.PeopleHistories)
}

0 comments on commit 3530ffb

Please sign in to comment.