Attach /r/n to msg to avoid extra write. Fix auth checks

This commit is contained in:
Derek Collison
2013-08-19 12:14:29 -07:00
parent cb6a71fb46
commit 8fa318738c
5 changed files with 55 additions and 15 deletions

View File

@@ -217,3 +217,22 @@ func TestSplitBufferPubOp4(t *testing.T) {
t.Fatalf("Unexpected size bytes: '%s' vs '%s'\n", c.pa.szb, "11")
}
}
func TestSplitBufferPubOp5(t *testing.T) {
c := &client{subs: hashmap.New()}
pubAll := []byte("PUB foo 11\r\nhello world\r\n")
// Splits need to be on MSG_END now too, so make sure we check that.
// Split between \r and \n
pub := pubAll[:len(pubAll)-1]
if err := c.parse(pub); err != nil {
t.Fatalf("Unexpected parse error: %v\n", err)
}
if c.msgBuf == nil {
t.Fatalf("msgBuf should not be nil!\n")
}
if !bytes.Equal(c.msgBuf, []byte("hello world\r")) {
t.Fatalf("c.msgBuf did not snaphot the msg")
}
}