ui/termstatus: cleanup test code

This commit is contained in:
Michael Eischer
2026-05-14 10:28:13 +02:00
parent df2d65bb88
commit 59697213f9
+13 -12
View File
@@ -20,31 +20,32 @@ func TestSetStatus(t *testing.T) {
cl = terminal.PosixControlClearLine
home = terminal.PosixControlMoveCursorHome
up = terminal.PosixControlMoveCursorUp
clearLn = home + cl
)
term.SetStatus([]string{"first"})
exp := home + cl + "first" + home
exp := clearLn + "first" + home
term.SetStatus([]string{""})
exp += home + cl + "" + home
exp += clearLn + "" + home
term.SetStatus([]string{})
exp += home + cl + "" + home
exp += clearLn + "" + home
// already empty status
term.SetStatus([]string{})
term.SetStatus([]string{"foo", "bar", "baz"})
exp += home + cl + "foo\n" + home + cl + "bar\n" +
home + cl + "baz" + home + up + up
exp += clearLn + "foo\n" + clearLn + "bar\n" + clearLn + "baz" + home + up + up
term.SetStatus([]string{"quux", "needs\nquote"})
exp += home + cl + "quux\n" +
home + cl + "\"needs\\nquote\"\n" +
home + cl + home + up + up // Clear third line
exp += clearLn + "quux\n" +
clearLn + "\"needs\\nquote\"\n" +
clearLn + home + up + up // Clear third line
cancel()
exp += home + cl + "\n" + home + cl + home + up // Status cleared
exp += clearLn + "\n" + clearLn + "" + home + up // Status cleared
<-term.closed
rtest.Equals(t, exp, buf.String())
@@ -58,10 +59,10 @@ func TestSetStatusUnchangedLines(t *testing.T) {
home = terminal.PosixControlMoveCursorHome
up = terminal.PosixControlMoveCursorUp
down = terminal.PosixControlMoveCursorDown
)
clearLn := home + cl
stepDown := home + down
clearLn = home + cl
stepDown = home + down
)
term.SetStatus([]string{"line1", "line2", "line3"})
exp := clearLn + "line1\n" + clearLn + "line2\n" + clearLn + "line3" + home + up + up