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 73f22e3 commit b5ccf39
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
15 changes: 5 additions & 10 deletions test/docker/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package aws
import (
"fmt"
"os"
"sync"
"testing"
"time"

Expand All @@ -32,7 +31,7 @@ const (

var (
runtime *awsRuntime
muTrace sync.Mutex
mtr *mocktracer.MockTracer
)

func TestMain(m *testing.M) {
Expand All @@ -43,6 +42,10 @@ func TestMain(m *testing.M) {
os.Exit(1)
}

mtr = mocktracer.New()
opentracing.SetGlobalTracer(mtr)
defer mtr.Reset()

exitCode := m.Run()

ee := runtime.Teardown()
Expand Down Expand Up @@ -190,11 +193,3 @@ 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
}
6 changes: 3 additions & 3 deletions test/docker/aws/consumer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type message struct {
}

func Test_SQS_Consume(t *testing.T) {
defer mtr.Reset()

const queueName = "test-sqs-consume"
const correlationID = "123"

Expand All @@ -30,9 +32,7 @@ func Test_SQS_Consume(t *testing.T) {
require.NoError(t, err)

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

mtr := setupTrace()
defer mtr.Reset()
mtr.Reset()

factory, err := sqsConsumer.NewFactory(
api,
Expand Down
17 changes: 5 additions & 12 deletions test/docker/aws/sns_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ import (
)

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

mtr := setupTrace()
defer mtr.Reset()

const topic = "test_publish_message"

api, err := createSNSAPI(runtime.getSNSEndpoint())
require.NoError(t, err)
arn, err := createSNSTopic(api, topic)
Expand All @@ -42,11 +41,10 @@ func Test_SNS_Publish_Message(t *testing.T) {
}

func Test_SNS_Publish_Message_v2(t *testing.T) {
const topic = "test_publish_message_v2"

mtr := setupTrace()
defer mtr.Reset()

const topic = "test_publish_message_v2"

api, err := createSNSAPI(runtime.getSNSEndpoint())
require.NoError(t, err)
arn, err := createSNSTopic(api, topic)
Expand All @@ -71,12 +69,7 @@ func Test_SNS_Publish_Message_v2(t *testing.T) {
}

func createMsg(t *testing.T, topicArn string) v1.Message {
b := v1.NewMessageBuilder()

msg, err := b.
Message("test msg").
TopicArn(topicArn).
Build()
msg, err := v1.NewMessageBuilder().Message("test msg").TopicArn(topicArn).Build()
require.NoError(t, err)
return *msg
}
2 changes: 0 additions & 2 deletions test/docker/aws/sqs_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type sampleMsg struct {
}

func Test_SQS_Publish_Message(t *testing.T) {
mtr := setupTrace()
defer mtr.Reset()

const queueName = "test-sqs-publish"
Expand Down Expand Up @@ -70,7 +69,6 @@ func Test_SQS_Publish_Message(t *testing.T) {
}

func Test_SQS_Publish_Message_v2(t *testing.T) {
mtr := setupTrace()
defer mtr.Reset()

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

0 comments on commit b5ccf39

Please sign in to comment.