Skip to content

Commit 0715e81

Browse files
committed
Fix tests
1 parent b50916d commit 0715e81

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/trace/trigger.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ describe("parseEventSource", () => {
174174
it("extracts all trigger tags", () => {
175175
for (let event of events) {
176176
const eventData = JSON.parse(readFileSync(`./event_samples/${event.file}`, "utf8"));
177-
const eventSource = parseEventSource(event);
177+
const eventSource = parseEventSource(eventData);
178178
const triggerTags = extractTriggerTags(eventData, mockContext, eventSource);
179179
expect(triggerTags).toEqual(event.result);
180180
}
@@ -183,7 +183,7 @@ describe("parseEventSource", () => {
183183
it("extracts the status code if API Gateway, ALB, or Function URL, otherwise do nothing, for buffered functions", () => {
184184
for (const event of events) {
185185
const eventData = JSON.parse(readFileSync(`./event_samples/${event.file}`, "utf8"));
186-
const eventSource = parseEventSource(event);
186+
const eventSource = parseEventSource(eventData);
187187
const triggerTags = extractTriggerTags(eventData, mockContext, eventSource);
188188
const isResponseStreamingFunction = false;
189189
for (const response of bufferedResponses) {
@@ -208,7 +208,7 @@ describe("parseEventSource", () => {
208208
it("extracts the status code if API Gateway, ALB, or Function URL, otherwise do nothing, for streaming functions", () => {
209209
for (let event of events) {
210210
const eventData = JSON.parse(readFileSync(`./event_samples/${event.file}`, "utf8"));
211-
const eventSource = parseEventSource(event);
211+
const eventSource = parseEventSource(eventData);
212212
const triggerTags = extractTriggerTags(eventData, mockContext, eventSource);
213213
const isResponseStreamingFunction = true;
214214
for (const response of streamingResponses) {

src/utils/span-pointers.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe("span-pointers utils", () => {
5151
eTag: "test-etag",
5252
},
5353
},
54+
eventName: "ObjectCreated:SomeEventName",
5455
},
5556
],
5657
};
@@ -79,6 +80,7 @@ describe("span-pointers utils", () => {
7980
eTag: "etag1",
8081
},
8182
},
83+
eventName: "ObjectCreated:SomeEventName",
8284
},
8385
{
8486
s3: {
@@ -88,6 +90,7 @@ describe("span-pointers utils", () => {
8890
eTag: "etag2",
8991
},
9092
},
93+
eventName: "ObjectCreated:SomeEventName",
9194
},
9295
],
9396
};
@@ -135,6 +138,7 @@ describe("span-pointers utils", () => {
135138
eTag: "valid-etag",
136139
},
137140
},
141+
eventName: "ObjectCreated:SomeEventName",
138142
},
139143
],
140144
};

src/utils/span-pointers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function processS3Event(event: any): SpanPointerAttributes[] {
5353

5454
for (const record of records) {
5555
const eventName = record.eventName;
56-
if (!eventName.startsWith("ObjectCreated")) {
56+
if (!eventName || !eventName.startsWith("ObjectCreated")) {
5757
continue;
5858
}
5959
// Values are stored in the same place, regardless of AWS SDK v2/v3 or the event type.

0 commit comments

Comments
 (0)