test: extract newMockEnvoy helper
This commit is contained in:
@@ -133,3 +133,16 @@ func newMockSessionHarness() *mockSessionHarness {
|
|||||||
terminate: terminate,
|
terminate: terminate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MockEnvoy
|
||||||
|
|
||||||
|
func newMockEnvoy(t *testing.T) (*mockPool, *Envoy) {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
p := newMockPool(t)
|
||||||
|
emb := NewEmbassy(p.ctx, p.plugin, nil)
|
||||||
|
err := emb.Dispatch(p.url)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
envoy := emb.Call(p.url)
|
||||||
|
return p, envoy
|
||||||
|
}
|
||||||
|
|||||||
+2
-10
@@ -208,11 +208,7 @@ func TestRequestManager_Session(t *testing.T) {
|
|||||||
|
|
||||||
func TestRequestManager_Stream(t *testing.T) {
|
func TestRequestManager_Stream(t *testing.T) {
|
||||||
t.Run("spawns session and sends req when connected", func(t *testing.T) {
|
t.Run("spawns session and sends req when connected", func(t *testing.T) {
|
||||||
p := newMockPool(t)
|
p, envoy := newMockEnvoy(t)
|
||||||
emb := NewEmbassy(p.ctx, p.plugin, nil)
|
|
||||||
err := emb.Dispatch(p.url)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
envoy := emb.Call(p.url)
|
|
||||||
|
|
||||||
p.connect()
|
p.connect()
|
||||||
Eventually(t, envoy.IsConnected, "envoy should be connected")
|
Eventually(t, envoy.IsConnected, "envoy should be connected")
|
||||||
@@ -239,11 +235,7 @@ func TestRequestManager_Stream(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("registers but does not spawn session when disconnected", func(t *testing.T) {
|
t.Run("registers but does not spawn session when disconnected", func(t *testing.T) {
|
||||||
p := newMockPool(t)
|
p, envoy := newMockEnvoy(t)
|
||||||
emb := NewEmbassy(p.ctx, p.plugin, nil)
|
|
||||||
err := emb.Dispatch(p.url)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
envoy := emb.Call(p.url)
|
|
||||||
|
|
||||||
m := NewRequestManager(envoy)
|
m := NewRequestManager(envoy)
|
||||||
filters := [][]byte{[]byte(`{}`)}
|
filters := [][]byte{[]byte(`{}`)}
|
||||||
|
|||||||
Reference in New Issue
Block a user