Skip to content

Commit 3991a9d

Browse files
committed
test: assert tenantId in JSON log output
Reuse the existing JSON-log test to verify tenantId is emitted as a top-level field in JSON-formatted logs, per review feedback on CR-290016955. cr: https://code.amazon.com/reviews/CR-290016955
1 parent 94e1e85 commit 3991a9d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎src/logging/log-patch.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ describe("LogPatch", async () => {
1010
const originalConsole = { ...console };
1111
const mockTimestamp = "2024-01-01T00:00:00.000Z";
1212
const mockRequestId = "test-request-id";
13+
const mockTenantId = "test-tenant-id";
1314

1415
const invokeStore = await InvokeStore.getInstanceAsync();
1516

@@ -25,6 +26,7 @@ describe("LogPatch", async () => {
2526

2627
// Mock InvokeStore
2728
vi.spyOn(invokeStore, "getRequestId").mockReturnValue(mockRequestId);
29+
vi.spyOn(invokeStore, "getTenantId").mockReturnValue(mockTenantId);
2830

2931
// Mock Date
3032
vi.spyOn(Date.prototype, "toISOString").mockReturnValue(mockTimestamp);
@@ -230,6 +232,9 @@ describe("LogPatch", async () => {
230232
expect(process.stdout.write).toHaveBeenCalledWith(
231233
expect.stringContaining(`"requestId":"${mockRequestId}"`),
232234
);
235+
expect(process.stdout.write).toHaveBeenCalledWith(
236+
expect.stringContaining(`"tenantId":"${mockTenantId}"`),
237+
);
233238
expect(process.stdout.write).toHaveBeenCalledWith(
234239
expect.stringContaining(`"level":"INFO"`),
235240
);

0 commit comments

Comments
 (0)