mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
Add a test for the task that ReadToEnd holds while it calls back
ReadToEnd marks its task as done before it calls then. Its callers enqueue their follow-up work onto the UI thread from then, so for a moment in between, no task is busy. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ae37d44bce
commit
b34691777d
@@ -522,3 +522,28 @@ func TestQueuedReadRequestsAreAnsweredWhenTheTaskStops(t *testing.T) {
|
||||
|
||||
assert.EqualValues(t, 2, answered.Load())
|
||||
}
|
||||
|
||||
// The callers of ReadToEnd hand their follow-up work to the UI thread from then, and
|
||||
// that work holds a task of its own from the moment it is enqueued. If the task that
|
||||
// ReadToEnd holds were done before then runs, lazygit would count as idle for a moment
|
||||
// in between, and an integration test would carry on before the follow-up work is done.
|
||||
func TestReadToEndHoldsItsTaskUntilThenReturns(t *testing.T) {
|
||||
noop := func() {}
|
||||
task := gocui.NewFakeTask()
|
||||
|
||||
manager := NewViewBufferManager(
|
||||
utils.NewDummyLog(), bytes.NewBuffer(nil), noop, noop, noop, noop, noop, noop,
|
||||
func() gocui.Task { return task },
|
||||
func(f func()) error { f(); return nil },
|
||||
)
|
||||
|
||||
// With no command task serving read requests, ReadToEnd answers right away.
|
||||
var statusDuringThen gocui.TaskStatus
|
||||
manager.ReadToEnd(func() { statusDuringThen = task.Status() })
|
||||
|
||||
/* EXPECTED:
|
||||
assert.Equal(t, gocui.TaskStatusBusy, statusDuringThen)
|
||||
ACTUAL: */
|
||||
assert.Equal(t, gocui.TaskStatusDone, statusDuringThen)
|
||||
assert.Equal(t, gocui.TaskStatusDone, task.Status())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user