package main import ( "testing" "github.com/stretchr/testify/require" ) func TestStopNameReadsTheNameOfASubagent(t *testing.T) { testCases := []struct { name string line string found bool agent string }{ { name: "a name after the command", line: " /stop GreenOtter ", found: true, agent: "GreenOtter", }, { name: "the command alone", line: "/stop", }, { name: "the command with spaces only", line: "/stop ", }, { name: "a word that starts with the command", line: "/stopGreenOtter", }, { name: "a message", line: "please /stop GreenOtter", }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { agent, found := stopSubagentName(tc.line) require.Equal(t, tc.found, found) require.Equal(t, tc.agent, agent) }) } }