Skip to content

Commit

Permalink
Quick push
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjohansen committed Jul 24, 2023
1 parent 29a2719 commit 7d49b80
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pkg/dispatcher/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ func (m MockAcknowledger) Reject(tag uint64, requeue bool) error {
}

type MockClient struct {
Request func(ctx context.Context, m binding.Message, transformers ...binding.Transformer) (binding.Message, error)
request func(ctx context.Context, m binding.Message, transformers ...binding.Transformer) (binding.Message, error)
}

func (mock MockClient) Request(ctx context.Context, m binding.Message, transformers ...binding.Transformer) (binding.Message, error) {
return mock.request(ctx, m, transformers...)
}

type MockStatsReporter struct {
Expand All @@ -217,14 +221,14 @@ func (m MockStatsReporter) ReportEventDispatchTime(args *dispatcherstats.ReportA
}

func TestDispatcher_dispatch(t *testing.T) {
notifyCloseChannel := make(chan *amqp.Error)
consumeChannel := make(<-chan amqp.Delivery)
//notifyCloseChannel := make(chan *amqp.Error, 1)
//consumeChannel := make(chan amqp.Delivery, 1)
channel := rabbit.RabbitMQChannelMock{
NotifyCloseChannel: notifyCloseChannel,
ConsumeChannel: consumeChannel,
//NotifyCloseChannel: notifyCloseChannel,
//ConsumeChannel: consumeChannel,
}

go func() {
/*go func() {
for {
select {
case consumer := <-consumeChannel:
Expand All @@ -233,7 +237,7 @@ func TestDispatcher_dispatch(t *testing.T) {
log.Fatalf(notify.Error())
}
}
}()
}()*/

type fields struct {
BrokerIngressURL string
Expand Down Expand Up @@ -302,7 +306,7 @@ func TestDispatcher_dispatch(t *testing.T) {
Body: []byte(`{"specversion":"1.0","source":"valid-event","id":"valid-id","type":"valid-type"}`),
},
client: MockClient{
Request: func(ctx context.Context, m binding.Message, transformers ...binding.Transformer) (binding.Message, error) {
request: func(ctx context.Context, m binding.Message, transformers ...binding.Transformer) (binding.Message, error) {
return m, v2.NewHTTPRetriesResult(v2.NewHTTPResult(500, ""), 0, time.Now(), []protocol.Result{})
},
},
Expand All @@ -324,7 +328,7 @@ func TestDispatcher_dispatch(t *testing.T) {
Body: []byte(`{"specversion":"1.0","source":"valid-event","id":"valid-id","type":"valid-type"}`),
},
client: MockClient{
Request: func(ctx context.Context, m binding.Message, transformers ...binding.Transformer) (binding.Message, error) {
request: func(ctx context.Context, m binding.Message, transformers ...binding.Transformer) (binding.Message, error) {
return m, v2.NewHTTPRetriesResult(v2.NewHTTPResult(200, ""), 0, time.Now(), []protocol.Result{})
},
},
Expand Down

0 comments on commit 7d49b80

Please sign in to comment.