Skip to content

Commit

Permalink
Update main_publisher_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
houseofcat committed Apr 16, 2021
1 parent ab307a1 commit 110270e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions v2/tests/main_publisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,47 @@ func TestBasicPublish(t *testing.T) {
amqpConn.Close()
}

// TestBasicPublishToNonExistentExchange tests what happen when a publish to exchange
// that doesn't exist also doesn't error. This is a demonstration of server
// side Dead Lettering.
func TestBasicPublishToNonExistentExchange(t *testing.T) {
defer leaktest.Check(t)()

letter := tcr.CreateMockLetter("DoesNotExist", "TcrTestQueue", nil)
amqpConn, err := amqp.Dial(Seasoning.PoolConfig.URI)
if err != nil {
t.Error(t, err)
return
}

amqpChan, err := amqpConn.Channel()
if err != nil {
t.Error(t, err)
return
}

err = amqpChan.Publish(
letter.Envelope.Exchange,
letter.Envelope.RoutingKey,
letter.Envelope.Mandatory,
letter.Envelope.Immediate,
amqp.Publishing{
ContentType: letter.Envelope.ContentType,
Body: letter.Body,
MessageId: letter.LetterID.String(),
Timestamp: time.Now().UTC(),
AppId: "TCR-Test",
})

if err != nil {
t.Error(t, err)
return
}

amqpChan.Close()
amqpConn.Close()
}

func TestCreatePublisherAndPublish(t *testing.T) {
defer leaktest.Check(t)() // Fail on leaked goroutines.

Expand Down

0 comments on commit 110270e

Please sign in to comment.