Skip to content

Commit

Permalink
handle empty body
Browse files Browse the repository at this point in the history
  • Loading branch information
adi.yaskolka committed Aug 30, 2019
1 parent 48317a1 commit 107f402
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
12 changes: 6 additions & 6 deletions tests/bus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func TestSendingPanic(t *testing.T) {
}

func TestEmptyBody(t *testing.T) {
b := createNamedBusForTest(testSvc5)
b := createNamedBusForTest(testSvc1)
proceed := make(chan bool)
b.SetGlobalRawMessageHandler(func(tx *sql.Tx, delivery *amqp.Delivery) error {
proceed <- true
Expand All @@ -496,7 +496,7 @@ func TestEmptyBody(t *testing.T) {
defer ch.Close()

cmd := amqp.Publishing{}
err = ch.Publish("", testSvc5, true, false, cmd)
err = ch.Publish("", testSvc1, true, false, cmd)
if err != nil {
t.Error("couldnt send message on rabbitmq channel")
}
Expand All @@ -509,7 +509,7 @@ func TestEmptyMessageInvokesDeadHanlder(t *testing.T) {
should handle the message successfully.
*/

b := createBusWithConfig(testSvc5, "grabbit-dead", true, true,
b := createBusWithConfig(testSvc1, "grabbit-dead", true, true,
gbus.BusConfiguration{MaxRetryCount: 0, BaseRetryDuration: 0})

proceed := make(chan bool)
Expand Down Expand Up @@ -538,7 +538,7 @@ func TestEmptyMessageInvokesDeadHanlder(t *testing.T) {
headersMap := make(map[string]interface{})
headersMap["x-death"] = make([]interface{}, 0)
cmd := amqp.Publishing{Headers: headersMap}
err = ch.Publish("", testSvc5, true, false, cmd)
err = ch.Publish("", testSvc1, true, false, cmd)
if err != nil {
t.Error("couldnt send message on rabbitmq channel")
}
Expand All @@ -560,7 +560,7 @@ func TestFailHandlerInvokeOfMessageWithEmptyBody(t *testing.T) {
proceed <- true
return nil
})
err := b.HandleMessage(&Command3{}, func(invocation gbus.Invocation, message *gbus.BusMessage) error {
err := b.HandleMessage(Command1{}, func(invocation gbus.Invocation, message *gbus.BusMessage) error {
t.Error("handler invoked for non-grabbit message")
return nil
})
Expand All @@ -587,7 +587,7 @@ func TestFailHandlerInvokeOfMessageWithEmptyBody(t *testing.T) {
defer ch.Close()

headersMap := make(map[string]interface{})
headersMap["x-msg-name"] = Command3{}.SchemaName()
headersMap["x-msg-name"] = Command1{}.SchemaName()
cmd := amqp.Publishing{Headers: headersMap}
err = ch.Publish("", testSvc1, true, false, cmd)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions tests/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ var testSvc1 string
var testSvc2 string
var testSvc3 string
var testSvc4 string
var testSvc5 string

func init() {
connStr = "amqp://rabbitmq:rabbitmq@localhost"
testSvc1 = "testSvc1"
testSvc2 = "testSvc2"
testSvc3 = "testSvc3"
testSvc4 = "test-svc4"
testSvc5 = "test-svc5"
}

func createBusWithConfig(svcName string, deadletter string, txnl, pos bool, conf gbus.BusConfiguration) gbus.Bus {
Expand Down
8 changes: 0 additions & 8 deletions tests/testMessages.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ func (Command2) SchemaName() string {
return "grabbit.tests.Command2"
}

type Command3 struct {
Data string
}

func (Command3) SchemaName() string {
return "grabbit.tests.Command3"
}

type Reply1 struct {
Data string
}
Expand Down

0 comments on commit 107f402

Please sign in to comment.