milvus/pkg/streaming/util/message/message_test.go
chyezh cc8f7aa110
fix: streaming service related fix patch (#34696)
issue: #33285

- add idAlloc interface
- fix binary unsafe bug for message
- fix service discovery lost when repeated address with different server
id

---------

Signed-off-by: chyezh <chyezh@outlook.com>
2024-07-16 15:49:38 +08:00

34 lines
776 B
Go

package message
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestMessageType(t *testing.T) {
s := MessageTypeUnknown.marshal()
assert.Equal(t, "0", s)
typ := unmarshalMessageType("0")
assert.Equal(t, MessageTypeUnknown, typ)
assert.False(t, MessageTypeUnknown.Valid())
typ = unmarshalMessageType("882s9")
assert.Equal(t, MessageTypeUnknown, typ)
s = MessageTypeTimeTick.marshal()
typ = unmarshalMessageType(s)
assert.Equal(t, MessageTypeTimeTick, typ)
assert.True(t, MessageTypeTimeTick.Valid())
}
func TestVersion(t *testing.T) {
v := newMessageVersionFromString("")
assert.Equal(t, VersionOld, v)
assert.Panics(t, func() {
newMessageVersionFromString("s1")
})
v = newMessageVersionFromString("1")
assert.Equal(t, VersionV1, v)
}