Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiyan-sheng committed May 7, 2020
1 parent 28fd667 commit 70c10ef
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions x-pack/filebeat/input/s3/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ func TestHandleMessage(t *testing.T) {
},
},
},
{
"sqs message with event source aws:s3, event name ObjectCreated:Put and encoded filename",
sqs.Message{
Body: awssdk.String("{\"Records\":[{\"eventSource\":\"aws:s3\",\"awsRegion\":\"ap-southeast-1\",\"eventTime\":\"2019-06-21T16:16:54.629Z\",\"eventName\":\"ObjectCreated:Put\",\"s3\":{\"configurationId\":\"object-created-event\",\"bucket\":{\"name\":\"test-s3-ks-2\",\"arn\":\"arn:aws:s3:::test-s3-ks-2\"},\"object\":{\"key\":\"year%3D2020/month%3D05/test1.txt\"}}}]}"),
},
[]s3Info{
{
name: "test-s3-ks-2",
key: "year=2020/month=05/test1.txt",
},
},
},
{
"sqs message with event source aws:s3, event name ObjectCreated:Put and gzip filename",
sqs.Message{
Body: awssdk.String("{\"Records\":[{\"eventSource\":\"aws:s3\",\"awsRegion\":\"ap-southeast-1\",\"eventTime\":\"2019-06-21T16:16:54.629Z\",\"eventName\":\"ObjectCreated:Put\",\"s3\":{\"configurationId\":\"object-created-event\",\"bucket\":{\"name\":\"test-s3-ks-2\",\"arn\":\"arn:aws:s3:::test-s3-ks-2\"},\"object\":{\"key\":\"428152502467_CloudTrail_us-east-2_20191219T1655Z_WXCas1PVnOaTpABD.json.gz\"}}}]}"),
},
[]s3Info{
{
name: "test-s3-ks-2",
key: "428152502467_CloudTrail_us-east-2_20191219T1655Z_WXCas1PVnOaTpABD.json.gz",
},
},
},
}

for _, c := range casesPositive {
Expand Down

0 comments on commit 70c10ef

Please sign in to comment.