fix issues TUI display reliability
This commit is contained in:
1 parent
a96e95212a
commit
f5015581a4
5 files changed
+84
-5
No files matched your search
@@ -251,3 +251,26 @@ func TestBarAndMinimal(t *testing.T) {
|
||||
t.Fatalf("minimal render should surface scan errors, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestModelKeepsLastGoodSnapshotOnScanError(t *testing.T) {
|
||||
m := newModel(nil, modelConfig{Interval: time.Minute})
|
||||
good := snapshot{ScannedAt: time.Now(), Issues: []issueView{{}}}
|
||||
updated, _ := m.Update(snapshotMsg(good))
|
||||
m = updated.(model)
|
||||
|
||||
failed := snapshot{Err: context.DeadlineExceeded}
|
||||
updated, _ = m.Update(snapshotMsg(failed))
|
||||
m = updated.(model)
|
||||
if len(m.snap.Issues) != 1 {
|
||||
t.Fatalf("failed scan should not erase the last good snapshot: %+v", m.snap)
|
||||
}
|
||||
if m.scanErr == nil {
|
||||
t.Fatal("failed scan should be visible separately from the last good snapshot")
|
||||
}
|
||||
|
||||
updated, _ = m.Update(snapshotMsg(snapshot{ScannedAt: time.Now()}))
|
||||
m = updated.(model)
|
||||
if m.scanErr != nil {
|
||||
t.Fatal("successful scan should clear the previous scan error")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user