Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nhulston committed Nov 22, 2024
1 parent b50916d commit 0715e81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/trace/trigger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe("parseEventSource", () => {
it("extracts all trigger tags", () => {
for (let event of events) {
const eventData = JSON.parse(readFileSync(`./event_samples/${event.file}`, "utf8"));
const eventSource = parseEventSource(event);
const eventSource = parseEventSource(eventData);
const triggerTags = extractTriggerTags(eventData, mockContext, eventSource);
expect(triggerTags).toEqual(event.result);
}
Expand All @@ -183,7 +183,7 @@ describe("parseEventSource", () => {
it("extracts the status code if API Gateway, ALB, or Function URL, otherwise do nothing, for buffered functions", () => {
for (const event of events) {
const eventData = JSON.parse(readFileSync(`./event_samples/${event.file}`, "utf8"));
const eventSource = parseEventSource(event);
const eventSource = parseEventSource(eventData);
const triggerTags = extractTriggerTags(eventData, mockContext, eventSource);
const isResponseStreamingFunction = false;
for (const response of bufferedResponses) {
Expand All @@ -208,7 +208,7 @@ describe("parseEventSource", () => {
it("extracts the status code if API Gateway, ALB, or Function URL, otherwise do nothing, for streaming functions", () => {
for (let event of events) {
const eventData = JSON.parse(readFileSync(`./event_samples/${event.file}`, "utf8"));
const eventSource = parseEventSource(event);
const eventSource = parseEventSource(eventData);
const triggerTags = extractTriggerTags(eventData, mockContext, eventSource);
const isResponseStreamingFunction = true;
for (const response of streamingResponses) {
Expand Down
4 changes: 4 additions & 0 deletions src/utils/span-pointers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe("span-pointers utils", () => {
eTag: "test-etag",
},
},
eventName: "ObjectCreated:SomeEventName",
},
],
};
Expand Down Expand Up @@ -79,6 +80,7 @@ describe("span-pointers utils", () => {
eTag: "etag1",
},
},
eventName: "ObjectCreated:SomeEventName",
},
{
s3: {
Expand All @@ -88,6 +90,7 @@ describe("span-pointers utils", () => {
eTag: "etag2",
},
},
eventName: "ObjectCreated:SomeEventName",
},
],
};
Expand Down Expand Up @@ -135,6 +138,7 @@ describe("span-pointers utils", () => {
eTag: "valid-etag",
},
},
eventName: "ObjectCreated:SomeEventName",
},
],
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/span-pointers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function processS3Event(event: any): SpanPointerAttributes[] {

for (const record of records) {
const eventName = record.eventName;
if (!eventName.startsWith("ObjectCreated")) {
if (!eventName || !eventName.startsWith("ObjectCreated")) {
continue;
}
// Values are stored in the same place, regardless of AWS SDK v2/v3 or the event type.
Expand Down

0 comments on commit 0715e81

Please sign in to comment.