Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
gunli committed Jul 11, 2023
1 parent e72a275 commit aa8895a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions pulsar/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ import (
"testing"
"time"

"github.com/apache/pulsar-client-go/pulsar/internal"
"github.com/stretchr/testify/assert"

"github.com/apache/pulsar-client-go/pulsar/internal"

log "github.com/sirupsen/logrus"

"github.com/apache/pulsar-client-go/pulsar/crypto"
plog "github.com/apache/pulsar-client-go/pulsar/log"
log "github.com/sirupsen/logrus"
)

func TestInvalidURL(t *testing.T) {
Expand Down Expand Up @@ -111,6 +113,12 @@ func TestSimpleProducer(t *testing.T) {

_, err = producer.Send(context.Background(), nil)
assert.NotNil(t, err)

_, err = producer.Send(context.Background(), &ProducerMessage{
Payload: []byte("hello"),
Value: []byte("hello"),
})
assert.NotNil(t, err)
}

func TestProducerAsyncSend(t *testing.T) {
Expand Down Expand Up @@ -163,6 +171,15 @@ func TestProducerAsyncSend(t *testing.T) {
wg.Done()
})
wg.Wait()

wg.Add(1)
producer.SendAsync(context.Background(), &ProducerMessage{Payload: []byte("hello"), Value: []byte("hello")},
func(id MessageID, m *ProducerMessage, e error) {
assert.NotNil(t, e)
assert.Nil(t, id)
wg.Done()
})
wg.Wait()
}

func TestProducerCompression(t *testing.T) {
Expand Down Expand Up @@ -1600,7 +1617,7 @@ func TestMultipleSchemaOfKeyBasedBatchProducerConsumer(t *testing.T) {
}
producer.Flush()

//// create consumer
// // create consumer
consumer, err := client.Subscribe(ConsumerOptions{
Topic: topic,
SubscriptionName: "my-sub2",
Expand Down Expand Up @@ -1691,7 +1708,7 @@ func TestMultipleSchemaProducerConsumer(t *testing.T) {
}
producer.Flush()

//// create consumer
// // create consumer
consumer, err := client.Subscribe(ConsumerOptions{
Topic: topic,
SubscriptionName: "my-sub2",
Expand Down

0 comments on commit aa8895a

Please sign in to comment.