7.21 杭州源创会火热报名中,一起来看看移动开发如何紧跟浪潮?
Watch Star Fork

rushmore / zbus-goGoMIT

加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
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 )

你可以在登录后,发表评论

11_float_left_people 11_float_left_close