Files
w3cjandClaude Opus 5.5 8e851cddf4 feat(ui): devvm's logo atop the root help, the first run and each new VM's summary
The logo prints from the UI alone (ui.UI.Logo, msg.Reporter's Logo), once
a run, only with stdout a terminal (or a test build's PickOnPipe), not with
--no-input, --json or names mode; its mark green, plain under NO_COLOR. The
CLI reference's pages don't get it: only the root's help func prints it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 00:35:59 -07:00

47 lines
1.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package ui
import "testing"
func TestLogo(t *testing.T) {
const plain = "╭──────────╮\n│ ❯ devvm ╭┤\n╰─────────██\n"
const colored = "╭──────────╮\n│ \033[32m❯\033[0m devvm ╭┤\n╰─────────██\n"
for _, tc := range []struct {
name string
terminal, pipe, noInput bool
dataOnly, names, colorOn bool
want string
}{
{name: "terminal, colored", terminal: true, colorOn: true, want: colored},
{name: "terminal, NO_COLOR", terminal: true, want: plain},
{name: "PickOnPipe", pipe: true, want: plain},
{name: "no terminal"},
{name: "names mode", terminal: true, names: true},
{name: "no input", terminal: true, noInput: true},
{name: "json", terminal: true, dataOnly: true},
} {
t.Run(tc.name, func(t *testing.T) {
u, out, _ := testUI(t, "")
u.stdoutTTY = tc.terminal
u.pickOnPipe.Store(tc.pipe)
u.noInput.Store(tc.noInput)
u.dataOnly.Store(tc.dataOnly)
u.outStyle = style{on: tc.colorOn, names: tc.names}
u.Logo()
u.Logo() // once a run
if got := out.String(); got != tc.want {
t.Errorf("Logo printed %q, want %q", got, tc.want)
}
})
}
}
// NO_COLOR turns the logo's color off in a terminal, as colorOn has it.
func TestLogoNoColor(t *testing.T) {
if s := newStyle(env{"NO_COLOR": "1"}.get, true); s.logo() != logoText {
t.Errorf("NO_COLOR's logo is %q, want it plain", s.logo())
}
if s := newStyle(env{"DEVVM_MESSAGES": "names"}.get, true); !s.names {
t.Error("DEVVM_MESSAGES=names isn't names mode")
}
}