Skip to content

Commit

Permalink
Fixing tests to include a valid ARN
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-stanchev committed Apr 20, 2023
1 parent 1a2478f commit c055fa0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
15 changes: 10 additions & 5 deletions consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ import (
)

const testConsumerGroup = "testGroup"
const testARN = "arn:aws:kafka:eu-west-1:123456789012:cluster/testCluster/12345678-1234-1234-1234-123456789012-1"

var testMessages = []*sarama.ConsumerMessage{{Value: []byte("Message1")}, {Value: []byte("Message2")}}

type clusterDescriberMock struct {
describeCluster func(ctx context.Context, input *kafka.DescribeClusterV2Input, optFns ...func(*kafka.Options)) (*kafka.DescribeClusterV2Output, error)
}

func strAsPtr(s string) *string {
return &s
}

func (cd *clusterDescriberMock) DescribeClusterV2(ctx context.Context, input *kafka.DescribeClusterV2Input, optFns ...func(*kafka.Options)) (*kafka.DescribeClusterV2Output, error) {
if cd.describeCluster != nil {
return cd.describeCluster(ctx, input, optFns...)
Expand Down Expand Up @@ -79,7 +84,7 @@ func TestConsumer_Connectivity(t *testing.T) {
newConsumer: func() *Consumer {
return &Consumer{
config: ConsumerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: "unknown:9092",
},
clusterDescriber: &clusterDescriberMock{
Expand All @@ -97,7 +102,7 @@ func TestConsumer_Connectivity(t *testing.T) {
newConsumer: func() *Consumer {
return &Consumer{
config: ConsumerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: "unknown:9092",
},
clusterDescriber: &clusterDescriberMock{
Expand All @@ -119,7 +124,7 @@ func TestConsumer_Connectivity(t *testing.T) {
newConsumer: func() *Consumer {
return &Consumer{
config: ConsumerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: "unknown:9092",
},
clusterDescriber: &clusterDescriberMock{
Expand All @@ -145,7 +150,7 @@ func TestConsumer_Connectivity(t *testing.T) {

return &Consumer{
config: ConsumerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: broker.Addr(),
},
clusterDescriber: &clusterDescriberMock{
Expand All @@ -171,7 +176,7 @@ func TestConsumer_Connectivity(t *testing.T) {

return &Consumer{
config: ConsumerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: broker.Addr(),
},
clusterDescriber: &clusterDescriberMock{
Expand Down
10 changes: 5 additions & 5 deletions producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestProducer_Connectivity(t *testing.T) {
newProducer: func() *Producer {
return &Producer{
config: ProducerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: "unknown:9092",
},
clusterDescriber: &clusterDescriberMock{
Expand All @@ -100,7 +100,7 @@ func TestProducer_Connectivity(t *testing.T) {
newProducer: func() *Producer {
return &Producer{
config: ProducerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: "unknown:9092",
},
clusterDescriber: &clusterDescriberMock{
Expand All @@ -122,7 +122,7 @@ func TestProducer_Connectivity(t *testing.T) {
newProducer: func() *Producer {
return &Producer{
config: ProducerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: "unknown:9092",
},
clusterDescriber: &clusterDescriberMock{
Expand All @@ -148,7 +148,7 @@ func TestProducer_Connectivity(t *testing.T) {

return &Producer{
config: ProducerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: broker.Addr(),
},
clusterDescriber: &clusterDescriberMock{
Expand All @@ -174,7 +174,7 @@ func TestProducer_Connectivity(t *testing.T) {

return &Producer{
config: ProducerConfig{
ClusterArn: new(string),
ClusterArn: strAsPtr(testARN),
BrokersConnectionString: broker.Addr(),
},
clusterDescriber: &clusterDescriberMock{
Expand Down

0 comments on commit c055fa0

Please sign in to comment.