Protect referenced feeder structures from deletion
This commit is contained in:
parent
b893c72534
commit
855a04e655
13 changed files with 369 additions and 0 deletions
|
|
@ -291,6 +291,43 @@ describe("distribution-board subtree project command", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("blocks deleting a board subtree that feeds another board", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
const upstream = createPopulatedBoard(context);
|
||||
const downstream = new DistributionBoardFixtureRepository(
|
||||
context.db
|
||||
).createWithCircuitListAndDefaultSections("project-1", "Unterverteiler");
|
||||
context.db
|
||||
.update(distributionBoards)
|
||||
.set({
|
||||
boardNumber: "UV-03",
|
||||
feedingDistributionBoardId: upstream.id,
|
||||
})
|
||||
.where(eq(distributionBoards.id, downstream.id))
|
||||
.run();
|
||||
const repository =
|
||||
new DistributionBoardSubtreeProjectCommandRepository(context.db);
|
||||
const snapshot = repository.capture("project-1", upstream.id);
|
||||
|
||||
assert.throws(
|
||||
() =>
|
||||
repository.execute({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
source: "user",
|
||||
command:
|
||||
createDistributionBoardDeleteSubtreeProjectCommand(snapshot),
|
||||
}),
|
||||
/Speist UV-03 – erst Einspeisung ändern\./
|
||||
);
|
||||
assert.deepEqual(repository.capture("project-1", upstream.id), snapshot);
|
||||
assert.equal(context.db.select().from(projectRevisions).all().length, 0);
|
||||
} finally {
|
||||
context.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("rolls back a cascaded deletion when history persistence fails", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue