feat(caprover): allow human to mark an app as successfully updated

This commit is contained in:
Pierre Martin
2024-03-10 12:22:38 +01:00
parent 5c599842f6
commit 204efe8a8b
9 changed files with 215 additions and 12 deletions

20
services/Human.test.ts Normal file
View File

@@ -0,0 +1,20 @@
import { describe, expect, it } from "bun:test";
import { TestApp } from "../domain/testing/TestApp";
import Human from "./Human";
describe("Human", () => {
it("should mark the application as updated", () => {
const eventStore = new TestApp().eventStore;
const human = new Human(eventStore);
const appName = "MyApp";
human.markApplicationAsUpdated(appName);
const events = eventStore.getAllEvents();
expect(events).toBeArrayOfSize(1);
expect(events[0]).toMatchObject({
type: "ApplicationUpdateFinished",
payload: { id: "MyApp" },
});
});
});

17
services/Human.ts Normal file
View File

@@ -0,0 +1,17 @@
import EventStore from "../domain/EventStore";
import { ApplicationUpdateFinished } from "../domain/events/ApplicationUpdateFinished";
/**
* Actions done by a Human in the application
*/
class Human {
constructor(private eventStore: EventStore) {}
markApplicationAsUpdated(appName: string) {
this.eventStore.append(
new ApplicationUpdateFinished({ id: appName }, new Date())
);
}
}
export default Human;