From 55e92dddc3df52c78a770be5c8fb28f4636716d2 Mon Sep 17 00:00:00 2001 From: Jay Date: Sun, 17 May 2026 12:17:29 -0400 Subject: [PATCH] test: extract newMockEnvoy helper --- helpers_test.go | 13 +++++++++++++ request_test.go | 12 ++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/helpers_test.go b/helpers_test.go index 2c112b7..5995a88 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -133,3 +133,16 @@ func newMockSessionHarness() *mockSessionHarness { 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 +} diff --git a/request_test.go b/request_test.go index 1a814e1..d22b4fb 100644 --- a/request_test.go +++ b/request_test.go @@ -208,11 +208,7 @@ func TestRequestManager_Session(t *testing.T) { func TestRequestManager_Stream(t *testing.T) { t.Run("spawns session and sends req when connected", func(t *testing.T) { - p := newMockPool(t) - emb := NewEmbassy(p.ctx, p.plugin, nil) - err := emb.Dispatch(p.url) - assert.NoError(t, err) - envoy := emb.Call(p.url) + p, envoy := newMockEnvoy(t) p.connect() 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) { - p := newMockPool(t) - emb := NewEmbassy(p.ctx, p.plugin, nil) - err := emb.Dispatch(p.url) - assert.NoError(t, err) - envoy := emb.Call(p.url) + p, envoy := newMockEnvoy(t) m := NewRequestManager(envoy) filters := [][]byte{[]byte(`{}`)}