(c net.Conn)
| 164 | } |
| 165 | |
| 166 | func (s *mockRESP2Server) handle(c net.Conn) { |
| 167 | defer c.Close() |
| 168 | r := bufio.NewReader(c) |
| 169 | for { |
| 170 | args, err := readRESPCommand(r) |
| 171 | if err != nil { |
| 172 | return |
| 173 | } |
| 174 | if len(args) == 0 { |
| 175 | continue |
| 176 | } |
| 177 | name := strings.ToUpper(args[0]) |
| 178 | full := name |
| 179 | if len(args) > 1 { |
| 180 | full = name + " " + strings.ToUpper(args[1]) |
| 181 | } |
| 182 | s.mu.Lock() |
| 183 | s.commands = append(s.commands, full) |
| 184 | s.mu.Unlock() |
| 185 | |
| 186 | if name == "HELLO" { |
| 187 | _, _ = c.Write([]byte("-ERR unknown command 'hello'\r\n")) |
| 188 | continue |
| 189 | } |
| 190 | _, _ = c.Write([]byte("+OK\r\n")) |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | func startMockRESP2Server(t *testing.T) *mockRESP2Server { |
| 195 | t.Helper() |
no test coverage detected