Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhang.balkundi committed Oct 26, 2023
1 parent 462380a commit bbc6bac
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions mw/rabbitmq/int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
"github.com/gojekfarm/ziggurat"
)

func newAutoRetry(qn string, count int, consumerCount int) *ARetry {
func newAutoRetry(qn string, count int, consumerCount int, qtype int) *ARetry {
ar := AutoRetry(
[]QueueConfig{{
QueueKey: qn,
DelayExpirationInMS: "500",
RetryCount: count,
ConsumerCount: consumerCount,
Type: qtype,
}},
WithUsername("user"),
WithConnectionTimeout(5*time.Second),
Expand All @@ -43,13 +44,7 @@ func Test_RetryFlow(t *testing.T) {
QueueName: "foo",
ConsumerCount: 1,
},
{
PublishCount: 10,
RetryCount: 5,
Name: "spawns one consumer when the count is 0",
QueueName: "bar",
ConsumerCount: 1,
},

{
PublishCount: 10,
RetryCount: 2,
Expand All @@ -65,7 +60,7 @@ func Test_RetryFlow(t *testing.T) {
defer cfn()
var callCount int32
expectedCallCount := int32(c.PublishCount * c.RetryCount)
ar := newAutoRetry(c.QueueName, c.RetryCount, c.ConsumerCount)
ar := newAutoRetry(c.QueueName, c.RetryCount, c.ConsumerCount, RetryQueue)
err := ar.InitPublishers(ctx)
t.Logf("publishers init successful")
if err != nil {
Expand Down Expand Up @@ -147,7 +142,7 @@ func Test_view(t *testing.T) {

for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
ar := newAutoRetry(c.qname, 5, 1)
ar := newAutoRetry(c.qname, 5, 1, RetryQueue)
err := ar.InitPublishers(ctx)
if err != nil {
t.Errorf("error could not init publishers:%v", err)
Expand Down Expand Up @@ -222,7 +217,7 @@ func Test_replay(t *testing.T) {
defer cfn()
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
ar := newAutoRetry(tc.queueName, 5, 1)
ar := newAutoRetry(tc.queueName, 5, 1, RetryQueue)
err := ar.InitPublishers(ctx)
if err != nil {
t.Errorf("couldn't start publishers:%v", err)
Expand Down Expand Up @@ -263,7 +258,7 @@ func Test_MessageLoss(t *testing.T) {
qname := "foo"
ctx, cfn := context.WithTimeout(context.Background(), time.Second*10)
defer cfn()
ar := newAutoRetry(qname, retryCount, consumerCount)
ar := newAutoRetry(qname, retryCount, consumerCount, RetryQueue)

done := make(chan struct{})
go func() {
Expand Down Expand Up @@ -308,5 +303,4 @@ func Test_MessageLoss(t *testing.T) {
if err != nil {
t.Errorf("error deleting queues:%v", err)
}

}

0 comments on commit bbc6bac

Please sign in to comment.