From 1653f961759418ec9c64f89ccf54f297175b65c7 Mon Sep 17 00:00:00 2001 From: adatzer Date: Mon, 2 Dec 2024 18:54:29 +0200 Subject: [PATCH] Address review --- pkg/source/kinesis/kinesis_source_test.go | 74 ----------------------- 1 file changed, 74 deletions(-) diff --git a/pkg/source/kinesis/kinesis_source_test.go b/pkg/source/kinesis/kinesis_source_test.go index 34e44e56..e0fd71e6 100644 --- a/pkg/source/kinesis/kinesis_source_test.go +++ b/pkg/source/kinesis/kinesis_source_test.go @@ -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" @@ -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) {