diff --git a/go.mod b/go.mod index e6a64f9..0c54549 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/nats-io/nuid v1.0.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.31.0 // indirect - golang.org/x/net v0.25.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 34c96c5..78fb7e1 100644 --- a/go.sum +++ b/go.sum @@ -99,8 +99,9 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/nats/nats_test.go b/nats/nats_test.go index 417fa9c..2215205 100644 --- a/nats/nats_test.go +++ b/nats/nats_test.go @@ -1,3 +1,6 @@ +//go:build integration +// +build integration + package nats import ( diff --git a/redis/redis_test.go b/redis/redis_test.go index 9723795..b73ca10 100644 --- a/redis/redis_test.go +++ b/redis/redis_test.go @@ -1,3 +1,6 @@ +//go:build integration +// +build integration + package redis import ( diff --git a/registry_test.go b/registry_test.go index 632648b..661dad4 100644 --- a/registry_test.go +++ b/registry_test.go @@ -79,8 +79,7 @@ func TestChainFilter(t *testing.T) { logrus.Info("\n", chainFilters(pongs, f), "\n", chainFilters(pongs, f), "\n", chainFilters(pongs, f), "\n", chainFilters(pongs, f)) } - -func launchSubscriber(chstop chan interface{}, name string, addr string, kv ...string) { +func launchSubscriber3(chstop chan interface{}, chend chan interface{}, name string, addr string, kv ...string) { reg, _ := NewRegistry(WithPubsub(pb), WithRegisterInterval(500*time.Millisecond)) myaddr := addr host := "" @@ -104,6 +103,13 @@ func launchSubscriber(chstop chan interface{}, name string, addr string, kv ...s fn() } reg.Close() + close(chend) +} + +func launchSubscriber(chstop chan interface{}, name string, addr string, kv ...string) { + chend := make(chan interface{}) + launchSubscriber3(chstop, chend, name, addr, kv...) + <-chend } func TestRegWithDefaultInstance(t *testing.T) { @@ -646,14 +652,15 @@ func TestGetServiceWithFilter(t *testing.T) { ch := make(chan interface{}) r, _ := NewRegistry(WithPubsub(pb), WithTimeout(time.Millisecond*200)) serviceName := "TestGetServiceWithFilter" - go launchSubscriber(ch, serviceName, "999", "node", "primary") + chend := make(chan interface{}) + go launchSubscriber3(ch, chend, serviceName, "999", "node", "primary") assert.NotNil(t, r) s, err := r.GetService(serviceName) assert.Nil(t, err) assert.NotNil(t, s) //close chanel trigger unsubscribe close(ch) - time.Sleep(time.Millisecond * 30) + <-chend s, err = r.GetService(serviceName) assert.NotNil(t, err) assert.Nil(t, s) diff --git a/samples/test_test.go b/samples/test_test.go index f5066b7..4ecdcbd 100644 --- a/samples/test_test.go +++ b/samples/test_test.go @@ -1,3 +1,6 @@ +//go:build integration +// +build integration + package main import ( diff --git a/test/fakepubsub.go b/test/fakepubsub.go index 4432e06..ad73089 100644 --- a/test/fakepubsub.go +++ b/test/fakepubsub.go @@ -116,7 +116,7 @@ func (s *fakeServer) SendMessage(mes *pubsub.PubsubMsg) error { if subs, ok := m[mes.Subject]; ok { for _, v := range subs { - go v(mes) + v(mes) } } else { //subject is unknown @@ -124,7 +124,7 @@ func (s *fakeServer) SendMessage(mes *pubsub.PubsubMsg) error { m = s.getCachesub() if subs, ok = m[mes.Subject]; ok { for _, v := range subs { - go v(mes) + v(mes) } } }