Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
(fix) Wait for bus routine to finish in lcm tests
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Kim <[email protected]>
  • Loading branch information
jooskim committed Aug 3, 2021
1 parent e39a50c commit 782054e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion service/service_lifecycle_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/vmware/transport-go/model"
"net/http"
"sync"
"testing"
)

Expand Down Expand Up @@ -73,6 +74,7 @@ func TestServiceLifecycleManager_OverrideRESTBridgeConfig_NoSuchService(t *testi

func TestServiceLifecycleManager_OverrideRESTBridgeConfig(t *testing.T) {
// arrange
wg := sync.WaitGroup{}
sr := newTestServiceRegistry()
lcm := newTestServiceLifecycleManager(sr)
sr.lifecycleManager = lcm.(*serviceLifecycleManager)
Expand All @@ -92,6 +94,8 @@ func TestServiceLifecycleManager_OverrideRESTBridgeConfig(t *testing.T) {
stream, err := sr.bus.ListenStreamForDestination(LifecycleManagerChannelName, sr.bus.GetId())
assert.Nil(t, err)
defer stream.Close()

wg.Add(1)
stream.Handle(func(message *model.Message) {
req, parsed := message.Payload.(*SetupRESTBridgeRequest)
if !parsed {
Expand All @@ -100,12 +104,14 @@ func TestServiceLifecycleManager_OverrideRESTBridgeConfig(t *testing.T) {
// assert
assert.True(t, req.Override)
assert.EqualValues(t, "another-test-channel", req.ServiceChannel)
assert.EqualValues(t, payload, req)
assert.EqualValues(t, payload, req.Config[0])
wg.Done()
}, func(err error) {
assert.Fail(t, "should not have errored", err)
})

// act
err = lcm.OverrideRESTBridgeConfig("another-test-channel", []*RESTBridgeConfig{payload})
assert.Nil(t, err)
wg.Wait()
}

0 comments on commit 782054e

Please sign in to comment.