clean test code
This commit is contained in:
parent
11a198d2e9
commit
eeb05bc929
26
http_test.go
26
http_test.go
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -131,26 +130,19 @@ func TestSubscriber(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// publish
|
// publish
|
||||||
wg := sync.WaitGroup{}
|
mClient := client.NewClient(
|
||||||
go func() {
|
client.Registry(reg),
|
||||||
wg.Add(1)
|
client.Broker(srv.Options().Broker),
|
||||||
defer wg.Done()
|
)
|
||||||
mClient := client.NewClient(
|
pub := micro.NewPublisher(topic, mClient)
|
||||||
client.Registry(reg),
|
if err := pub.Publish(ctx, &api.Event{}); err != nil {
|
||||||
client.Transport(srv.Options().Transport),
|
t.Fatal(err)
|
||||||
client.Broker(srv.Options().Broker),
|
}
|
||||||
)
|
|
||||||
pub := micro.NewPublisher(topic, mClient)
|
|
||||||
if err := pub.Publish(ctx, &api.Event{}); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
// wait cancel
|
// wait cancel
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
if ctx.Err() != context.Canceled {
|
if ctx.Err() != context.Canceled {
|
||||||
t.Fatalf("subscriber is not working, err: %s", ctx.Err())
|
t.Fatalf("subscriber is not working")
|
||||||
}
|
}
|
||||||
|
|
||||||
// deregister server
|
// deregister server
|
||||||
|
Loading…
Reference in New Issue
Block a user