Skip to content

Commit eed3b67

Browse files
committed
feat(tests): add test for explicit AWS env values in local DynamoDB configuration
1 parent 53ff4e0 commit eed3b67

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

packages/ddb-publisher/src/__tests__/run.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,44 @@ describe("runPublisher", () => {
361361
}),
362362
).rejects.toThrow("status=<missing>");
363363
});
364+
365+
it("should use explicit AWS env values for local DynamoDB endpoints when provided", async () => {
366+
const store: LoadedConfigStore = {
367+
rootPath: "/tmp",
368+
records: [],
369+
};
370+
371+
fileStore.loadConfigStore.mockResolvedValue(store);
372+
fileStore.validateConfigStore.mockReturnValue({ ok: true, issues: [] });
373+
audit.auditBeforeLoad.mockResolvedValue({ blockingRecords: [] });
374+
375+
process.env.SUPPLIER_CONFIG_DDB_ENDPOINT_URL = "http://localhost:8000";
376+
process.env.AWS_REGION = "eu-central-1";
377+
process.env.AWS_ACCESS_KEY_ID = "customKey";
378+
process.env.AWS_SECRET_ACCESS_KEY = "customSecret";
379+
380+
try {
381+
await runPublisher({
382+
sourcePath: "/tmp",
383+
env: "draft",
384+
tableName: "tbl",
385+
dryRun: false,
386+
force: false,
387+
});
388+
389+
expect(awsClient.DynamoDBClient).toHaveBeenCalledWith({
390+
endpoint: "http://localhost:8000",
391+
region: "eu-central-1",
392+
credentials: {
393+
accessKeyId: "customKey",
394+
secretAccessKey: "customSecret",
395+
},
396+
});
397+
} finally {
398+
delete process.env.SUPPLIER_CONFIG_DDB_ENDPOINT_URL;
399+
delete process.env.AWS_REGION;
400+
delete process.env.AWS_ACCESS_KEY_ID;
401+
delete process.env.AWS_SECRET_ACCESS_KEY;
402+
}
403+
});
364404
});

0 commit comments

Comments
 (0)