@@ -14,6 +14,7 @@ import (
1414
1515 "github.com/DataDog/datadog-serverless-functions/aws/logs_monitoring_go/internal/config"
1616 "github.com/DataDog/datadog-serverless-functions/aws/logs_monitoring_go/internal/model"
17+ "github.com/aws/aws-lambda-go/events"
1718 "github.com/aws/aws-lambda-go/lambdacontext"
1819 "github.com/google/go-cmp/cmp"
1920)
@@ -43,7 +44,7 @@ func TestHandleKinesis(t *testing.T) {
4344 wantErr : true ,
4445 },
4546 "single log" : {
46- event : mustKinesisEvent (t , gzipJSON (t , map [string ]any {
47+ event : mustKinesisEvent (t , mustGzipJSON (t , map [string ]any {
4748 "messageType" : "DATA_MESSAGE" ,
4849 "owner" : "601427279990" ,
4950 "logGroup" : "/aws/lambda/testing-datadog" ,
@@ -77,7 +78,7 @@ func TestHandleKinesis(t *testing.T) {
7778 },
7879 "multiple records" : {
7980 event : mustKinesisEvent (t ,
80- gzipJSON (t , map [string ]any {
81+ mustGzipJSON (t , map [string ]any {
8182 "messageType" : "DATA_MESSAGE" ,
8283 "owner" : "111111111111" ,
8384 "logGroup" : "/aws/lambda/fn-a" ,
@@ -86,7 +87,7 @@ func TestHandleKinesis(t *testing.T) {
8687 {"id" : "a1" , "timestamp" : 1000 , "message" : "from-a" },
8788 },
8889 }),
89- gzipJSON (t , map [string ]any {
90+ mustGzipJSON (t , map [string ]any {
9091 "messageType" : "DATA_MESSAGE" ,
9192 "owner" : "222222222222" ,
9293 "logGroup" : "/aws/rds/cluster" ,
@@ -124,7 +125,7 @@ func TestHandleKinesis(t *testing.T) {
124125 "bad record is skipped" : {
125126 event : mustKinesisEvent (t ,
126127 []byte ("not valid gzip" ),
127- gzipJSON (t , map [string ]any {
128+ mustGzipJSON (t , map [string ]any {
128129 "messageType" : "DATA_MESSAGE" ,
129130 "owner" : "123456789012" ,
130131 "logGroup" : "/aws/lambda/good" ,
@@ -182,7 +183,7 @@ func TestHandleKinesis(t *testing.T) {
182183 }
183184}
184185
185- func gzipJSON (t * testing.T , v any ) []byte {
186+ func mustGzipJSON (t * testing.T , v any ) []byte {
186187 t .Helper ()
187188
188189 raw , err := json .Marshal (v )
@@ -206,19 +207,13 @@ func gzipJSON(t *testing.T, v any) []byte {
206207func mustKinesisEvent (t * testing.T , records ... []byte ) json.RawMessage {
207208 t .Helper ()
208209
209- type rec struct {
210- Kinesis struct {
211- Data []byte `json:"data"`
212- } `json:"kinesis"`
213- }
214- evt := struct {
215- Records []rec `json:"Records"`
216- }{}
217-
210+ var evt events.KinesisEvent
218211 for _ , data := range records {
219- r := rec {}
220- r .Kinesis .Data = data
221- evt .Records = append (evt .Records , r )
212+ evt .Records = append (evt .Records , events.KinesisEventRecord {
213+ Kinesis : events.KinesisRecord {
214+ Data : data ,
215+ },
216+ })
222217 }
223218
224219 raw , err := json .Marshal (evt )
0 commit comments