]> git.giacomolli.uk - onechat/blob - stop_test.go
Show stored images to the user
[onechat] / stop_test.go
1 package main
2
3 import (
4 "testing"
5
6 "github.com/stretchr/testify/require"
7 )
8
9 func TestStopNameReadsTheNameOfASubagent(t *testing.T) {
10 testCases := []struct {
11 name string
12 line string
13 found bool
14 agent string
15 }{
16 {
17 name: "a name after the command",
18 line: " /stop GreenOtter ",
19 found: true,
20 agent: "GreenOtter",
21 },
22 {
23 name: "the command alone",
24 line: "/stop",
25 },
26 {
27 name: "the command with spaces only",
28 line: "/stop ",
29 },
30 {
31 name: "a word that starts with the command",
32 line: "/stopGreenOtter",
33 },
34 {
35 name: "a message",
36 line: "please /stop GreenOtter",
37 },
38 }
39
40 for _, tc := range testCases {
41 t.Run(tc.name, func(t *testing.T) {
42 agent, found := stopSubagentName(tc.line)
43 require.Equal(t, tc.found, found)
44 require.Equal(t, tc.agent, agent)
45 })
46 }
47 }