Add automatic project snapshots
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import {
|
||||
automaticProjectSnapshotIntervalRevisions,
|
||||
automaticProjectSnapshotRetentionCount,
|
||||
shouldCaptureAutomaticProjectSnapshot,
|
||||
} from "../src/domain/models/project-snapshot-policy.model.js";
|
||||
|
||||
describe("automatic project snapshot policy", () => {
|
||||
it("captures every 25 revisions and retains twelve automatic snapshots", () => {
|
||||
assert.equal(automaticProjectSnapshotIntervalRevisions, 25);
|
||||
assert.equal(automaticProjectSnapshotRetentionCount, 12);
|
||||
assert.equal(
|
||||
shouldCaptureAutomaticProjectSnapshot(24, null),
|
||||
false
|
||||
);
|
||||
assert.equal(
|
||||
shouldCaptureAutomaticProjectSnapshot(25, null),
|
||||
true
|
||||
);
|
||||
assert.equal(
|
||||
shouldCaptureAutomaticProjectSnapshot(49, 25),
|
||||
false
|
||||
);
|
||||
assert.equal(
|
||||
shouldCaptureAutomaticProjectSnapshot(50, 25),
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects invalid or inconsistent revision inputs", () => {
|
||||
assert.throws(
|
||||
() => shouldCaptureAutomaticProjectSnapshot(-1, null),
|
||||
/non-negative integer/
|
||||
);
|
||||
assert.throws(
|
||||
() => shouldCaptureAutomaticProjectSnapshot(25, 26),
|
||||
/exceeds current revision/
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user