Преглед изворни кода

Fix #138

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev пре 6 година
родитељ
комит
0f4827b50b
2 измењених фајлова са 18 додато и 1 уклоњено
  1. 3 1
      leaves/burndown.go
  2. 15 0
      leaves/burndown_test.go

+ 3 - 1
leaves/burndown.go

@@ -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 {

+ 15 - 0
leaves/burndown_test.go

@@ -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)
+}