私信发送成功
Watch Star Fork

rushmore / zbus-goGoMIT

zbus Golang server and client https://zbus.io
克隆/下载
一键复制 编辑 原始数据 按行查看 历史
mq_test.go 1.16 KB rushmore 提交于 2017-08-16 19:18 . zbus-go server & client init
package main
import (
"encoding/json"
"fmt"
"testing"
)
var mq, _ = NewMessageQueue("/tmp/diskq", "hong")
func TestNewMessageQueue(t *testing.T) {
q, err := NewMessageQueue("/tmp/diskq", "hong")
if err != nil {
t.Fail()
}
defer q.Close()
}
func TestMessageQueue_Write(t *testing.T) {
msg := NewMessage()
msg.SetCmd("produce")
msg.SetBodyString("hello world")
err := mq.Write(msg)
if err != nil {
t.Fail()
}
}
func TestMessageQueue_ConsumeGroup(t *testing.T) {
g := &ConsumeGroup{}
g.GroupName = "hong"
g.Mask = &[]int32{0}[0]
fmt.Println(g.Mask)
}
func TestLoadMqTable(t *testing.T) {
table, err := LoadMqTable("/tmp/diskq")
if err != nil {
t.Fail()
}
println(table)
}
func TestMessageQueue_DeclareGroup(t *testing.T) {
group := &ConsumeGroup{}
group.GroupName = "hongx"
info, err := mq.DeclareGroup(group)
if err != nil {
t.Fail()
}
fmt.Println(info)
}
func TestMessageQueue_TopicInfo(t *testing.T) {
info := mq.TopicInfo()
data, _ := json.MarshalIndent(info, "", " ")
println(string(data))
}
func TestMessageQueue_Destroy(t *testing.T) {
mq, _ := NewMessageQueue("/tmp/tempmq", "hong2")
err := mq.Destroy()
if err != nil {
t.Fail()
}
}

评论 ( 0 )

你可以在登录后,对此项目发表评论

6_float_left_people 6_float_left_close