Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
FemiNoviaLina committed Oct 23, 2024
1 parent a7390e1 commit 8b8e742
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions internal/proxy/envoy/xds/ads/pubsub_test.go
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit 8b8e742

Please sign in to comment.