feat(caprover): allow human to mark an app as successfully updated
This commit is contained in:
20
services/Human.test.ts
Normal file
20
services/Human.test.ts
Normal 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
17
services/Human.ts
Normal 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;
|
||||
Reference in New Issue
Block a user