Initial Commit
This commit is contained in:
32
packages/api-stack/api/api-migrations/tests/property.test.ts
Normal file
32
packages/api-stack/api/api-migrations/tests/property.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, it } from "@suaveplan/testing/runner";
|
||||
import fc from "fast-check";
|
||||
import { computeChecksum } from "../src/runner/runner.js";
|
||||
|
||||
describe("property — SHA-256 checksum stability", () => {
|
||||
it("identical content produces identical SHA-256", {
|
||||
timeout: 30000,
|
||||
}, () => {
|
||||
fc.assert(
|
||||
fc.property(fc.string(), (content) => {
|
||||
const a = computeChecksum(content);
|
||||
const b = computeChecksum(content);
|
||||
return a === b && /^[0-9a-f]{64}$/.test(a);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it("different content produces different SHA-256", {
|
||||
timeout: 30000,
|
||||
}, () => {
|
||||
fc.assert(
|
||||
fc.property(
|
||||
fc.string({ minLength: 1 }),
|
||||
fc.string({ minLength: 1 }),
|
||||
(a, b) => {
|
||||
if (a === b) return true;
|
||||
return computeChecksum(a) !== computeChecksum(b);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user