You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
448 B
26 lines
448 B
|
1 year ago
|
package webstocetmsg
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"testing"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/sirupsen/logrus"
|
||
|
|
)
|
||
|
|
|
||
|
|
var ctx context.Context
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
ctx = context.Background()
|
||
|
|
}
|
||
|
|
|
||
|
|
// TestPublish 测试发布消息到redis
|
||
|
|
func TestPublish(t *testing.T) {
|
||
|
|
msg := "当前时间: " + time.Now().Format("15:04:05")
|
||
|
|
logrus.Debugf("[publish] msg: %s", msg)
|
||
|
|
err := Publish(ctx, PublishKey, msg)
|
||
|
|
if err != nil {
|
||
|
|
logrus.Errorf("publish error: %s", err.Error())
|
||
|
|
}
|
||
|
|
}
|