Skip to content

Commit

Permalink
update test to reflect new adjusted functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpaige committed Jan 2, 2025
1 parent 1e885fc commit 86aec81
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/libs/sink-lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,28 @@ describe("bulkUpdateDataWrapper", () => {
it("calls bulkUpdateData with correct arguments when env vars are defined", async () => {
const mockBulkUpdateData = vi.spyOn(os, "bulkUpdateData").mockImplementation(vi.fn());

vi.stubEnv("osDomain", OPENSEARCH_DOMAIN);
vi.stubEnv("indexNamespace", OPENSEARCH_INDEX_NAMESPACE);

await bulkUpdateDataWrapper(DOCS, "main");

expect(mockBulkUpdateData).toHaveBeenCalledWith(OPENSEARCH_DOMAIN, `${OPENSEARCH_INDEX_NAMESPACE}main`, DOCS);
expect(mockBulkUpdateData).toHaveBeenCalledWith(
OPENSEARCH_DOMAIN,
`${OPENSEARCH_INDEX_NAMESPACE}main`,
DOCS,
);
});

it("throws an Error when env vars are missing", async () => {
delete process.env.osDomain;
delete process.env.indexNamespace;
vi.stubEnv("osDomain", undefined);
vi.stubEnv("indexNamespace", undefined);

await expect(bulkUpdateDataWrapper(DOCS, "main")).rejects.toThrow(
"osDomain is undefined in environment variables",
);

vi.stubEnv("osDomain", "os-domain");
process.env.osDomain = OPENSEARCH_DOMAIN;
vi.stubEnv("osDomain", OPENSEARCH_DOMAIN);
vi.stubEnv("indexNamespace", undefined);

await expect(bulkUpdateDataWrapper(DOCS, "main")).rejects.toThrow(
"indexName is undefined in environment variables",
Expand Down

0 comments on commit 86aec81

Please sign in to comment.