Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738package workspace
import "testing"
func TestProcessLabel(t *testing.T) { for _, c := range []struct { name string p processInfo want string }{ {"shell at its prompt", processInfo{Foreground: &process{Name: "zsh", Argv0: "-zsh", Cwd: "/home/d/src/100gex"}}, "100gex"}, {"shell at home", processInfo{Foreground: &process{Name: "zsh", Cwd: "/home/d"}}, "~"}, {"a command under the shell", processInfo{Foreground: &process{Name: "nvim", Argv0: "nvim", Cwd: "/home/d"}, Ancestors: []*process{{Name: "zsh"}}}, "nvim"}, {"a script", processInfo{Foreground: &process{Name: "python3", Script: "/home/d/bin/train.py"}, Ancestors: []*process{{Name: "zsh"}}}, "train.py"}, {"a program run directly", processInfo{Foreground: &process{Name: "cat", Argv0: "cat", Cwd: "/tmp"}}, "cat"}, {"nothing", processInfo{}, ""}, } { if got := c.p.label("/home/d"); got != c.want { t.Errorf("%s: label = %q, want %q", c.name, got, c.want) } }}
func TestCleanTitle(t *testing.T) { for in, want := range map[string]string{ "◐ Rex terminal status indicators": "Rex terminal status indicators", "✳ Fix sidebar": "Fix sidebar", "⠋ Building ": "Building", "100gex": "100gex", "": "", "◐ ": "", } { if got := cleanTitle(in); got != want { t.Errorf("cleanTitle(%q) = %q, want %q", in, got, want) } }}