Initial catalog maker baseline
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { assertReadOnlySql } from "../src/lib/sql-readonly.js";
|
||||
|
||||
test("allows select statements", () => {
|
||||
assert.doesNotThrow(() => assertReadOnlySql("SELECT * FROM ps_product LIMIT 1"));
|
||||
});
|
||||
|
||||
test("blocks update statements", () => {
|
||||
assert.throws(
|
||||
() => assertReadOnlySql("UPDATE ps_product SET price = 0"),
|
||||
/Blocked non-read-only SQL statement: UPDATE/,
|
||||
);
|
||||
});
|
||||
|
||||
test("blocks insert statements after a leading comment", () => {
|
||||
assert.throws(
|
||||
() => assertReadOnlySql("-- old macro query\nINSERT INTO ps_product VALUES (1)"),
|
||||
/Blocked non-read-only SQL statement: INSERT/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user