mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +00:00
dispatch: channel reuse fix (#1237)
* Add test for dispatch channel reuse * Dispatcher - make chans bidirectional * No need to to keep the type assertion separate from the Get() * Unexport Pipe's channel and add getter
This commit is contained in:
@@ -183,7 +183,7 @@ func TestUnsubscribe(t *testing.T) {
|
||||
}
|
||||
|
||||
// will return nil if not running
|
||||
err = d.unsubscribe(nonEmptyUUID, make(<-chan interface{}))
|
||||
err = d.unsubscribe(nonEmptyUUID, make(chan interface{}))
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
@@ -193,7 +193,7 @@ func TestUnsubscribe(t *testing.T) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
|
||||
err = d.unsubscribe(nonEmptyUUID, make(<-chan interface{}))
|
||||
err = d.unsubscribe(nonEmptyUUID, make(chan interface{}))
|
||||
if !errors.Is(err, errDispatcherUUIDNotFoundInRouteList) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, errDispatcherUUIDNotFoundInRouteList)
|
||||
}
|
||||
@@ -203,7 +203,7 @@ func TestUnsubscribe(t *testing.T) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
|
||||
err = d.unsubscribe(id, make(<-chan interface{}))
|
||||
err = d.unsubscribe(id, make(chan interface{}))
|
||||
if !errors.Is(err, errChannelNotFoundInUUIDRef) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, errChannelNotFoundInUUIDRef)
|
||||
}
|
||||
@@ -223,6 +223,16 @@ func TestUnsubscribe(t *testing.T) {
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
|
||||
ch2, err := d.subscribe(id)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
|
||||
err = d.unsubscribe(id, ch2)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPublish(t *testing.T) {
|
||||
@@ -416,7 +426,7 @@ func TestMux(t *testing.T) {
|
||||
return
|
||||
}
|
||||
errChan <- nil
|
||||
}(pipe.C, errChan, &wg)
|
||||
}(pipe.c, errChan, &wg)
|
||||
|
||||
wg.Wait()
|
||||
|
||||
@@ -496,7 +506,7 @@ func TestMuxPublish(t *testing.T) {
|
||||
}
|
||||
}(mux)
|
||||
|
||||
<-pipe.C
|
||||
<-pipe.Channel()
|
||||
|
||||
// Shut down dispatch system
|
||||
err = d.stop()
|
||||
|
||||
Reference in New Issue
Block a user