Skip to content

Commit

Permalink
Fixed broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mantzas committed Dec 29, 2020
1 parent f117152 commit 73f22e3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
10 changes: 10 additions & 0 deletions test/docker/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/aws/aws-sdk-go/service/sqs/sqsiface"
patronDocker "github.com/beatlabs/patron/test/docker"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/mocktracer"
"github.com/ory/dockertest"
)

Expand Down Expand Up @@ -188,3 +190,11 @@ func createSQSQueue(api sqsiface.SQSAPI, queueName string) (string, error) {
}
return *out.QueueUrl, nil
}

func setupTrace() *mocktracer.MockTracer {
muTrace.Lock()
defer muTrace.Unlock()
mtr := mocktracer.New()
opentracing.SetGlobalTracer(mtr)
return mtr
}
7 changes: 1 addition & 6 deletions test/docker/aws/consumer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import (
patronSQS "github.com/beatlabs/patron/client/sqs"
sqsConsumer "github.com/beatlabs/patron/component/async/sqs"
"github.com/beatlabs/patron/correlation"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
"github.com/opentracing/opentracing-go/mocktracer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -33,11 +31,8 @@ func Test_SQS_Consume(t *testing.T) {

sent := sendMessage(t, api, correlationID, queue, "1", "2", "3")

muTrace.Lock()
mtr := mocktracer.New()
mtr := setupTrace()
defer mtr.Reset()
opentracing.SetGlobalTracer(mtr)
muTrace.Unlock()

factory, err := sqsConsumer.NewFactory(
api,
Expand Down
12 changes: 2 additions & 10 deletions test/docker/aws/sns_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,16 @@ import (
"github.com/aws/aws-sdk-go/service/sns"
v1 "github.com/beatlabs/patron/client/sns"
v2 "github.com/beatlabs/patron/client/sns/v2"
opentracing "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
"github.com/opentracing/opentracing-go/mocktracer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_SNS_Publish_Message(t *testing.T) {
const topic = "test_publish_message"

muTrace.Lock()
mtr := mocktracer.New()
mtr := setupTrace()
defer mtr.Reset()
opentracing.SetGlobalTracer(mtr)
muTrace.Unlock()

api, err := createSNSAPI(runtime.getSNSEndpoint())
require.NoError(t, err)
Expand All @@ -49,11 +44,8 @@ func Test_SNS_Publish_Message(t *testing.T) {
func Test_SNS_Publish_Message_v2(t *testing.T) {
const topic = "test_publish_message_v2"

muTrace.Lock()
mtr := mocktracer.New()
mtr := setupTrace()
defer mtr.Reset()
opentracing.SetGlobalTracer(mtr)
muTrace.Unlock()

api, err := createSNSAPI(runtime.getSNSEndpoint())
require.NoError(t, err)
Expand Down
12 changes: 2 additions & 10 deletions test/docker/aws/sqs_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import (
"github.com/aws/aws-sdk-go/service/sqs"
patronsqs "github.com/beatlabs/patron/client/sqs"
patronsqsv2 "github.com/beatlabs/patron/client/sqs/v2"
opentracing "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
"github.com/opentracing/opentracing-go/mocktracer"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -24,11 +22,8 @@ type sampleMsg struct {
}

func Test_SQS_Publish_Message(t *testing.T) {
muTrace.Lock()
mtr := mocktracer.New()
mtr := setupTrace()
defer mtr.Reset()
opentracing.SetGlobalTracer(mtr)
muTrace.Unlock()

const queueName = "test-sqs-publish"

Expand Down Expand Up @@ -75,11 +70,8 @@ func Test_SQS_Publish_Message(t *testing.T) {
}

func Test_SQS_Publish_Message_v2(t *testing.T) {
muTrace.Lock()
mtr := mocktracer.New()
mtr := setupTrace()
defer mtr.Reset()
opentracing.SetGlobalTracer(mtr)
muTrace.Unlock()

const queueName = "test-sqs-publish-v2"

Expand Down

0 comments on commit 73f22e3

Please sign in to comment.