Skip to content

Commit

Permalink
adding tests to sinkMainProcessors
Browse files Browse the repository at this point in the history
  • Loading branch information
thetif committed Jan 13, 2025
1 parent d2df3ee commit 0a1a856
Show file tree
Hide file tree
Showing 14 changed files with 734 additions and 508 deletions.
54 changes: 0 additions & 54 deletions lib/lambda/sinkBackup.ts

This file was deleted.

21 changes: 5 additions & 16 deletions lib/lambda/sinkMain.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, it, expect, vi, afterEach } from "vitest";
import { describe, it, expect, vi } from "vitest";
import { handler } from "./sinkMain";
import { Context } from "aws-lambda";
import * as sinkMainProcessors from "./sinkMainProcessors";
import { KafkaEvent } from "shared-types";

Expand All @@ -10,24 +11,12 @@ const createKafkaEvent = (records: KafkaEvent["records"]) => ({
});

describe("sinkMain handler", () => {
vi.stubEnv("osDomain", "os-domain");
vi.stubEnv("indexNamespace", "index-namespace");

afterEach(() => {
vi.restoreAllMocks();
vi.resetModules();
});

it("handles aws.onemac.migration.cdc topic successfully", async () => {
const spiedOnProcessAndIndex = vi
.spyOn(sinkMainProcessors, "insertOneMacRecordsFromKafkaIntoMako")
.mockImplementation(vi.fn());

await handler(
createKafkaEvent({ "aws.onemac.migration.cdc-0": [] }),
expect.anything(),
vi.fn(),
);
await handler(createKafkaEvent({ "aws.onemac.migration.cdc-0": [] }), {} as Context, vi.fn());

expect(spiedOnProcessAndIndex).toBeCalledWith([], "aws.onemac.migration.cdc-0");
});
Expand All @@ -39,7 +28,7 @@ describe("sinkMain handler", () => {

await handler(
createKafkaEvent({ "aws.seatool.ksql.onemac.three.agg.State_Plan-0": [] }),
expect.anything(),
{} as Context,
vi.fn(),
);

Expand All @@ -56,7 +45,7 @@ describe("sinkMain handler", () => {

await handler(
createKafkaEvent({ "aws.seatool.debezium.changed_date.SEA.dbo.State_Plan-0": [] }),
expect.anything(),
{} as Context,
vi.fn(),
);

Expand Down
Loading

0 comments on commit 0a1a856

Please sign in to comment.