Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556package tui
import ( "testing"
"albedo/cli/internal/daemon")
func TestCommandMenuMatchesArgumentChoices(t *testing.T) { menu := CommandMenuModel{Catalog: []daemon.SessionCommand{ {Name: "/reload", Arguments: []daemon.CommandArgument{{Name: "target", Description: "reload target", Choices: []string{"session", "models", "both"}}}}, {Name: "/reload", Arguments: []daemon.CommandArgument{{Name: "target", Choices: []string{"models", "other"}}}}, {Name: "/research", Arguments: []daemon.CommandArgument{{Name: "prompt"}}}, }} tests := []struct { input string want []string }{ {input: "/reload ", want: []string{"/reload session", "/reload models", "/reload both", "/reload other"}}, {input: "/reload m", want: []string{"/reload models"}}, {input: "/reload both", want: []string{"/reload both"}}, {input: "/research some words"}, {input: "/unknown "}, {input: "/reload\n", want: nil}, } for _, test := range tests { t.Run(test.input, func(t *testing.T) { matches := menu.Matches(test.input) if len(matches) != len(test.want) { t.Fatalf("got %v, want %v", commandNames(matches), test.want) } for index, match := range matches { if match.Name != test.want[index] { t.Fatalf("got %v, want %v", commandNames(matches), test.want) } } }) }}
func commandNames(matches []ChatCommand) []string { result := make([]string, len(matches)) for index, match := range matches { result[index] = match.Name } return result}
func TestCommandMenuMatchesNames(t *testing.T) { menu := CommandMenuModel{} matches := menu.Matches("/rel") if len(matches) == 0 || matches[0].Name != "/reload" { t.Fatalf("got %v, want /reload name completion", commandNames(matches)) }}