feat: MSK, MSK CONNECT and SES
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createMskRouter } from "./msk";
|
||||
import { type mskService } from "../services/msk";
|
||||
|
||||
function createService() {
|
||||
return {
|
||||
listClusters: async () => [{ ClusterName: "orders" }],
|
||||
createCluster: async () => ({ ClusterArn: "arn:cluster:orders" }),
|
||||
listTopics: async () => [{ name: "orders", partitionCount: 1 }],
|
||||
createTopic: async () => {},
|
||||
deleteTopic: async () => {},
|
||||
produceMessage: async () => [{ topicName: "orders", partition: 0, baseOffset: "0" }],
|
||||
peekMessages: async () => [{ value: "hello" }],
|
||||
consumerGroupLag: async () => [{ topic: "orders", totalLag: 0, partitions: [] }],
|
||||
} as unknown as typeof mskService;
|
||||
}
|
||||
|
||||
describe("msk routes", () => {
|
||||
test("serves clusters", async () => {
|
||||
const app = createMskRouter(createService());
|
||||
|
||||
const clusters = await app.request("/clusters");
|
||||
expect(clusters.status).toBe(200);
|
||||
expect(await clusters.json()).toEqual([{ ClusterName: "orders" }]);
|
||||
|
||||
});
|
||||
|
||||
test("serves topic, message, and consumer group operations through the API", async () => {
|
||||
const app = createMskRouter(createService());
|
||||
|
||||
const topic = await app.request("/clusters/cluster-arn/topics");
|
||||
expect(await topic.json()).toEqual([{ name: "orders", partitionCount: 1 }]);
|
||||
|
||||
const create = await app.request("/clusters/cluster-arn/topics", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ topic: "events" }),
|
||||
});
|
||||
expect(create.status).toBe(201);
|
||||
|
||||
const produced = await app.request("/clusters/cluster-arn/topics/orders/messages", {
|
||||
method: "POST",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify({ value: "hello" }),
|
||||
});
|
||||
expect(produced.status).toBe(201);
|
||||
|
||||
const messages = await app.request("/clusters/cluster-arn/topics/orders/messages?limit=1");
|
||||
expect(await messages.json()).toEqual([{ value: "hello" }]);
|
||||
|
||||
const lag = await app.request("/clusters/cluster-arn/consumer-groups/orders-workers/lag");
|
||||
expect(await lag.json()).toEqual([{ topic: "orders", totalLag: 0, partitions: [] }]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user