31 lines
1.6 KiB
TypeScript
31 lines
1.6 KiB
TypeScript
// @ts-nocheck
|
|
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
|
|
const schema = fs.readFileSync("sql/local-scrape-db.sql", "utf8");
|
|
|
|
test("local scrape schema stores image binaries with exact and visual hashes", () => {
|
|
assert.match(schema, /CREATE TABLE IF NOT EXISTS `scrape_image_blobs`/);
|
|
assert.match(schema, /`sha256` CHAR\(64\) NOT NULL/);
|
|
assert.match(schema, /`perceptual_hash` CHAR\(16\) NULL/);
|
|
assert.match(schema, /`image_data` LONGBLOB NOT NULL/);
|
|
assert.match(schema, /UNIQUE KEY `uq_scrape_image_blobs_sha256` \(`sha256`\)/);
|
|
});
|
|
|
|
test("local scrape schema tracks picture candidates and their target combination logic", () => {
|
|
assert.match(schema, /CREATE TABLE IF NOT EXISTS `scrape_picture_candidates`/);
|
|
assert.match(schema, /`target_strategy` ENUM\('unknown', 'color', 'size', 'combination', 'manual'\)/);
|
|
assert.match(schema, /`target_color` VARCHAR\(255\) NULL/);
|
|
assert.match(schema, /`target_size` VARCHAR\(128\) NULL/);
|
|
assert.match(schema, /`target_combi` VARCHAR\(255\) NULL/);
|
|
assert.match(schema, /`duplicate_status` ENUM\('unique', 'exact_duplicate', 'visual_duplicate', 'review'\)/);
|
|
});
|
|
|
|
test("local scrape schema can learn picture target rules from manual corrections", () => {
|
|
assert.match(schema, /CREATE TABLE IF NOT EXISTS `scrape_picture_target_rules`/);
|
|
assert.match(schema, /`product_name_pattern` VARCHAR\(255\) NULL/);
|
|
assert.match(schema, /`target_strategy` ENUM\('color', 'size', 'combination', 'manual'\) NOT NULL/);
|
|
assert.match(schema, /`examples_count` INT UNSIGNED NOT NULL DEFAULT 0/);
|
|
});
|