git/githistory/log: handle tasks with no output
This commit is contained in:
parent
fcc1522bed
commit
6bd752e674
@ -203,7 +203,12 @@ func (l *Logger) logTask(task Task) {
|
||||
}
|
||||
}
|
||||
|
||||
l.log(fmt.Sprintf("%s, done\n", update.S))
|
||||
if update != nil {
|
||||
// If a task sent no updates, the last recorded update will be
|
||||
// nil. Given this, only log a message when there was at least
|
||||
// (1) update.
|
||||
l.log(fmt.Sprintf("%s, done\n", update.S))
|
||||
}
|
||||
}
|
||||
|
||||
// logLine writes a complete line and moves the cursor to the beginning of the
|
||||
|
@ -175,3 +175,16 @@ func TestLoggerLogsAllDurableUpdates(t *testing.T) {
|
||||
"second, done\n",
|
||||
}, ""), buf.String())
|
||||
}
|
||||
|
||||
func TestLoggerHandlesSilentTasks(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
task := make(chan *Update)
|
||||
close(task)
|
||||
|
||||
l := NewLogger(&buf)
|
||||
l.Enqueue(ChanTask(task))
|
||||
l.Close()
|
||||
|
||||
assert.Equal(t, "", buf.String())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user