From 8b8e742616385503675dd37c5a63534dcc589090 Mon Sep 17 00:00:00 2001 From: Femi Novia Lina Date: Wed, 23 Oct 2024 14:54:43 +0700 Subject: [PATCH] test: add test --- internal/proxy/envoy/xds/ads/pubsub_test.go | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 internal/proxy/envoy/xds/ads/pubsub_test.go diff --git a/internal/proxy/envoy/xds/ads/pubsub_test.go b/internal/proxy/envoy/xds/ads/pubsub_test.go new file mode 100644 index 000000000..1868df09a --- /dev/null +++ b/internal/proxy/envoy/xds/ads/pubsub_test.go @@ -0,0 +1,28 @@ +package ads_test + +import ( + "errors" + "testing" + + "github.com/goto/shield/internal/proxy/envoy/xds/ads" + "github.com/stretchr/testify/assert" +) + +func TestPush(t *testing.T) { + message := ads.Message{ + NodeID: "node-1", + VersionInfo: "v1", + Nonce: "test", + TypeUrl: ads.CLUSTER_TYPE_URL, + } + messageChan := make(ads.MessageChan, 1) + + err := messageChan.Push(message) + recv := <-messageChan + assert.NoError(t, err) + assert.Equal(t, message, recv) + + close(messageChan) + err = messageChan.Push(message) + assert.True(t, errors.Is(err, ads.ErrChannelClosed)) +}