45 Star 300 Fork 75

GVPYoMo/yomo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
source_test.go 887 Bytes
一键复制 编辑 原始数据 按行查看 历史
package yomo
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/yomorun/yomo/core"
"github.com/yomorun/yomo/core/ylog"
)
func TestSource(t *testing.T) {
t.Parallel()
// source
source := NewSource(
"test-source",
"localhost:9000",
WithCredential("token:<CREDENTIAL>"),
WithLogger(ylog.Default()),
WithSourceQuicConfig(core.DefaultClientQuicConfig),
WithSourceTLSConfig(nil),
)
exit := make(chan struct{})
time.AfterFunc(time.Second, func() {
source.Close()
close(exit)
})
// error handler
source.SetErrorHandler(func(err error) {})
// connect to zipper from source
err := source.Connect()
assert.Nil(t, err)
// send data to zipper from source
err = source.Write(0x21, []byte("test"))
assert.Nil(t, err)
err = source.WriteWithTarget(0x22, []byte("message from source"), mockTargetString)
assert.Nil(t, err)
<-exit
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yomorun/yomo.git
git@gitee.com:yomorun/yomo.git
yomorun
yomo
yomo
master

搜索帮助