Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
adatzer committed Dec 2, 2024
1 parent b22062b commit 1653f96
Showing 1 changed file with 0 additions and 74 deletions.
74 changes: 0 additions & 74 deletions pkg/source/kinesis/kinesis_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"testing"
"time"

"github.com/davecgh/go-spew/spew"
"github.com/google/uuid"
"github.com/hashicorp/hcl/v2/hclparse"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -370,78 +368,6 @@ func TestKinesisSourceHCL(t *testing.T) {
}
}

func TestClientNamePassThrough(t *testing.T) {
if testing.Short() {
t.Skip("skipping integration test")
}

assert := assert.New(t)

filename := filepath.Join(assets.AssetsRootDir, "test", "config", "configs", "empty.hcl")
t.Setenv("SNOWBRIDGE_CONFIG_FILE", filename)

clientName := "testt_client_name"
kinesisClient := testutil.GetAWSLocalstackKinesisClient()
dynamodbClient := testutil.GetAWSLocalstackDynamoDBClient()
streamName := "kinesis-source-config-integration-4"
createErr := testutil.CreateAWSLocalstackKinesisStream(kinesisClient, streamName, 1)
if createErr != nil {
t.Fatal(createErr)
}
defer testutil.DeleteAWSLocalstackKinesisStream(kinesisClient, streamName)

appName := "kinesisSourceIntegration"
ddbErr := testutil.CreateAWSLocalstackDynamoDBTables(dynamodbClient, appName)
if ddbErr != nil {
t.Fatal(ddbErr)
}
defer testutil.DeleteAWSLocalstackDynamoDBTables(dynamodbClient, appName)

// Construct the config
c, err := config.NewConfig()
assert.NotNil(c)
if err != nil {
t.Fatalf("function NewConfig failed with error: %q", err.Error())
}

configBytesToMerge := []byte(fmt.Sprintf(`
stream_name = "%s"
region = "%s"
app_name = "%s"
client_name = "%s"
`, streamName, testutil.AWSLocalstackRegion, appName, clientName))

parser := hclparse.NewParser()
fileHCL, diags := parser.ParseHCL(configBytesToMerge, "placeholder")
if diags.HasErrors() {
t.Fatalf("failed to parse config bytes")
}

c.Data.Source.Use.Name = "kinesis"
c.Data.Source.Use.Body = fileHCL.Body
decoderOpts := &config.DecoderOptions{
Input: c.Data.Source.Use.Body,
}
plug := adapterGenerator(configFunctionGeneratorWithInterfaces(kinesisClient, dynamodbClient, "00000000000"))
result, err := c.CreateComponent(plug, decoderOpts)
assert.NotNil(result)
if err != nil {
t.Fatalf("failed to CreateComponent with error: %q", err.Error())
}

// workaround since clientName is unexported by Kinsumer
kinesisSource, ok := result.(*kinesisSource)
if !ok {
t.Fatal("result is not of type pointer to kinesisSource")
}

spewed := spew.Sdump(kinesisSource.client)
re := regexp.MustCompile(fmt.Sprintf(`clientName: \(string\) \(len=%d\) \"(.{%d})\"`, len(clientName), len(clientName)))
m := re.FindStringSubmatch(spewed)
assert.Equal(len(m), 2)
assert.Equal(m[1], clientName)
}

// Helpers
func testKinesisSourceAdapter(f func(c *Configuration) (*Configuration, error)) adapter {
return func(i interface{}) (interface{}, error) {
Expand Down

0 comments on commit 1653f96

Please sign in to comment.