-
Notifications
You must be signed in to change notification settings - Fork 847
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for ARNs in kinesis components
- Loading branch information
Showing
7 changed files
with
241 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package aws | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestStreamIDParser(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
id string | ||
remaining string | ||
shard string | ||
errContains string | ||
}{ | ||
{ | ||
name: "no shards stream name", | ||
id: "foo-bar", | ||
remaining: "foo-bar", | ||
}, | ||
{ | ||
name: "no shards stream arn", | ||
id: "arn:aws:kinesis:region:account-id:stream/stream-name", | ||
remaining: "arn:aws:kinesis:region:account-id:stream/stream-name", | ||
}, | ||
{ | ||
name: "sharded stream name", | ||
id: "foo-bar:baz", | ||
remaining: "foo-bar", | ||
shard: "baz", | ||
}, | ||
{ | ||
name: "sharded stream arn", | ||
id: "arn:aws:kinesis:region:account-id:stream/stream-name:baz", | ||
remaining: "arn:aws:kinesis:region:account-id:stream/stream-name", | ||
shard: "baz", | ||
}, | ||
{ | ||
name: "multiple shards stream name", | ||
id: "foo-bar:baz:buz", | ||
errContains: "only one shard should be specified", | ||
}, | ||
{ | ||
name: "multiple shards stream arn", | ||
id: "arn:aws:kinesis:region:account-id:stream/stream-name:baz:buz", | ||
errContains: "only one shard should be specified", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
test := test | ||
t.Run(test.name, func(t *testing.T) { | ||
rem, shard, err := parseStreamID(test.id) | ||
if test.errContains != "" { | ||
require.Error(t, err) | ||
assert.Contains(t, err.Error(), test.errContains) | ||
} else { | ||
require.NoError(t, err) | ||
assert.Equal(t, test.remaining, rem) | ||
assert.Equal(t, test.shard, shard) | ||
} | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters