Skip to content

Commit 3530ffb

Browse files
authored
Merge pull request #139 from vmarkovtsev/master
Fix #138
2 parents 7b7c6f3 + 0f4827b commit 3530ffb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

leaves/burndown.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ func (analyser *BurndownAnalysis) Finalize() interface{} {
368368
globalHistory, lastDay := analyser.groupSparseHistory(analyser.globalHistory, -1)
369369
fileHistories := map[string]DenseHistory{}
370370
for key, history := range analyser.fileHistories {
371-
fileHistories[key], _ = analyser.groupSparseHistory(history, lastDay)
371+
if len(history) > 0 {
372+
fileHistories[key], _ = analyser.groupSparseHistory(history, lastDay)
373+
}
372374
}
373375
peopleHistories := make([]DenseHistory, analyser.PeopleNumber)
374376
for i, history := range analyser.peopleHistories {

leaves/burndown_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -1170,3 +1170,18 @@ func TestBurndownDeserialize(t *testing.T) {
11701170
assert.Equal(t, result.granularity, 30)
11711171
assert.Equal(t, result.sampling, 30)
11721172
}
1173+
1174+
func TestBurndownEmptyFileHistory(t *testing.T) {
1175+
burndown := &BurndownAnalysis{
1176+
Sampling: 30,
1177+
Granularity: 30,
1178+
globalHistory: sparseHistory{0: map[int]int64{0: 10}},
1179+
fileHistories: map[string]sparseHistory{"test.go": {}},
1180+
}
1181+
res := burndown.Finalize().(BurndownResult)
1182+
assert.Len(t, res.GlobalHistory, 1)
1183+
assert.Len(t, res.FileHistories, 0)
1184+
assert.NotNil(t, res.FileHistories)
1185+
assert.Len(t, res.PeopleHistories, 0)
1186+
assert.NotNil(t, res.PeopleHistories)
1187+
}

0 commit comments

Comments
 (0)