1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-11-29 21:47:44 +02:00

remove unnecessary dependencies between plugins

remove unnecessary dependencies between plugins
upgrade go-micro.dev/v4 to v4.2.1
This commit is contained in:
Johnson C
2021-10-23 16:20:42 +08:00
committed by GitHub
parent f96b48dad9
commit af3cfa0a4c
206 changed files with 745 additions and 676 deletions

50
broker/memory_test.go Normal file
View File

@@ -0,0 +1,50 @@
package broker_test
import (
"fmt"
"testing"
"go-micro.dev/v4/broker"
)
func TestMemoryBroker(t *testing.T) {
b := broker.NewMemoryBroker()
if err := b.Connect(); err != nil {
t.Fatalf("Unexpected connect error %v", err)
}
topic := "test"
count := 10
fn := func(p broker.Event) error {
return nil
}
sub, err := b.Subscribe(topic, fn)
if err != nil {
t.Fatalf("Unexpected error subscribing %v", err)
}
for i := 0; i < count; i++ {
message := &broker.Message{
Header: map[string]string{
"foo": "bar",
"id": fmt.Sprintf("%d", i),
},
Body: []byte(`hello world`),
}
if err := b.Publish(topic, message); err != nil {
t.Fatalf("Unexpected error publishing %d", i)
}
}
if err := sub.Unsubscribe(); err != nil {
t.Fatalf("Unexpected error unsubscribing from %s: %v", topic, err)
}
if err := b.Disconnect(); err != nil {
t.Fatalf("Unexpected connect error %v", err)
}
}