migrate maintenance to use suites
This commit is contained in:
parent
afef0c0e61
commit
625456ec76
@ -1,4 +1,4 @@
|
||||
const test = require("node:test");
|
||||
const { describe, test } = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
const dayjs = require("dayjs");
|
||||
const { SQL_DATETIME_FORMAT } = require("../../src/util");
|
||||
@ -11,20 +11,19 @@ dayjs.extend(require("dayjs/plugin/customParseFormat"));
|
||||
* Issue: MariaDB rejects ISO format dates like '2025-12-19T01:04:02.129Z'
|
||||
* Fix: Use SQL_DATETIME_FORMAT ('YYYY-MM-DD HH:mm:ss') instead of toISOString()
|
||||
*/
|
||||
test("Maintenance Date Format - MariaDB Compatibility", async (t) => {
|
||||
|
||||
await t.test("SQL_DATETIME_FORMAT constant should match MariaDB format", async () => {
|
||||
describe("Maintenance Date Format - MariaDB Compatibility", () => {
|
||||
test("SQL_DATETIME_FORMAT constant should match MariaDB format", () => {
|
||||
assert.strictEqual(SQL_DATETIME_FORMAT, "YYYY-MM-DD HH:mm:ss");
|
||||
});
|
||||
|
||||
await t.test("Format date using SQL_DATETIME_FORMAT", async () => {
|
||||
test("format() produces SQL-compatible datetime string", () => {
|
||||
const current = dayjs.utc("2025-12-19T01:04:02.129Z");
|
||||
const sqlFormat = current.utc().format(SQL_DATETIME_FORMAT);
|
||||
|
||||
assert.strictEqual(sqlFormat, "2025-12-19 01:04:02");
|
||||
});
|
||||
});move websokcet
|
||||
|
||||
await t.test("SQL format should not contain ISO markers (T, Z)", async () => {
|
||||
test("SQL format does not contain ISO markers (T, Z)", () => {
|
||||
const current = dayjs.utc("2025-12-19T01:04:02.129Z");
|
||||
const sqlFormat = current.utc().format(SQL_DATETIME_FORMAT);
|
||||
|
||||
@ -32,7 +31,7 @@ test("Maintenance Date Format - MariaDB Compatibility", async (t) => {
|
||||
assert.strictEqual(sqlFormat.includes("Z"), false, "SQL format should not contain 'Z'");
|
||||
});
|
||||
|
||||
await t.test("SQL format should match YYYY-MM-DD HH:mm:ss pattern", async () => {
|
||||
test("SQL format matches YYYY-MM-DD HH:mm:ss pattern", () => {
|
||||
const current = dayjs.utc("2025-12-19T01:04:02.129Z");
|
||||
const sqlFormat = current.utc().format(SQL_DATETIME_FORMAT);
|
||||
const sqlDateTimeRegex = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/;
|
||||
@ -40,7 +39,7 @@ test("Maintenance Date Format - MariaDB Compatibility", async (t) => {
|
||||
assert.strictEqual(sqlDateTimeRegex.test(sqlFormat), true);
|
||||
});
|
||||
|
||||
await t.test("Parse SQL datetime back to dayjs preserves timestamp", async () => {
|
||||
test("parsing SQL datetime back to dayjs preserves timestamp", () => {
|
||||
const originalDate = dayjs.utc("2025-12-19T01:04:02.000Z");
|
||||
const sqlFormat = originalDate.utc().format(SQL_DATETIME_FORMAT);
|
||||
const parsedDate = dayjs.utc(sqlFormat, SQL_DATETIME_FORMAT);
|
||||
@ -48,18 +47,17 @@ test("Maintenance Date Format - MariaDB Compatibility", async (t) => {
|
||||
assert.strictEqual(parsedDate.unix(), originalDate.unix());
|
||||
});
|
||||
|
||||
await t.test("Edge case: midnight timestamp", async () => {
|
||||
test("formats midnight timestamp correctly", () => {
|
||||
const midnight = dayjs.utc("2025-01-01T00:00:00.000Z");
|
||||
const sqlFormat = midnight.utc().format(SQL_DATETIME_FORMAT);
|
||||
|
||||
assert.strictEqual(sqlFormat, "2025-01-01 00:00:00");
|
||||
});
|
||||
|
||||
await t.test("Edge case: end of day timestamp", async () => {
|
||||
test("formats end of day timestamp correctly", () => {
|
||||
const endOfDay = dayjs.utc("2025-12-31T23:59:59.999Z");
|
||||
const sqlFormat = endOfDay.utc().format(SQL_DATETIME_FORMAT);
|
||||
|
||||
assert.strictEqual(sqlFormat, "2025-12-31 23:59:59");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user