clean test code
This commit is contained in:
parent
11a198d2e9
commit
eeb05bc929
10
http_test.go
10
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{}
|
|
||||||
go func() {
|
|
||||||
wg.Add(1)
|
|
||||||
defer wg.Done()
|
|
||||||
mClient := client.NewClient(
|
mClient := client.NewClient(
|
||||||
client.Registry(reg),
|
client.Registry(reg),
|
||||||
client.Transport(srv.Options().Transport),
|
|
||||||
client.Broker(srv.Options().Broker),
|
client.Broker(srv.Options().Broker),
|
||||||
)
|
)
|
||||||
pub := micro.NewPublisher(topic, mClient)
|
pub := micro.NewPublisher(topic, mClient)
|
||||||
if err := pub.Publish(ctx, &api.Event{}); err != nil {
|
if err := pub.Publish(ctx, &api.Event{}); err != nil {
|
||||||
t.Fatal(err)
|
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