github.com/vmware/transport-go@v1.3.4/bridge/bridge_client_test.go (about) 1 // Copyright 2019-2020 VMware, Inc. 2 // SPDX-License-Identifier: BSD-2-Clause 3 4 package bridge 5 6 import ( 7 "github.com/go-stomp/stomp/v3/frame" 8 "github.com/stretchr/testify/assert" 9 "github.com/vmware/transport-go/model" 10 "log" 11 "os" 12 "sync" 13 "testing" 14 ) 15 16 func TestBridgeClient_Disconnect(t *testing.T) { 17 18 bc := new(BridgeClient) 19 e := bc.Disconnect() 20 assert.NotNil(t, e) 21 } 22 23 func TestBridgeClient_handleCommands(t *testing.T) { 24 d := "rainbow-land" 25 bc := new(BridgeClient) 26 i := make(chan *frame.Frame, 1) 27 e := make(chan *model.Message, 1) 28 29 l := log.New(os.Stderr, "WebSocket Client: ", 2) 30 bc.logger = l 31 bc.inboundChan = i 32 bc.Subscriptions = make(map[string]*BridgeClientSub) 33 s := &BridgeClientSub{E: e, Destination: d} 34 bc.Subscriptions[d] = s 35 36 go bc.handleIncomingSTOMPFrames() 37 wg := sync.WaitGroup{} 38 39 var sendError = func() { 40 f := frame.New(frame.ERROR, frame.Destination, d) 41 bc.inboundChan <- f 42 wg.Done() 43 } 44 wg.Add(1) 45 go sendError() 46 wg.Wait() 47 m := <-s.E 48 assert.Error(t, m.Error) 49 }