mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-07-08 01:31:00 +08:00
Update
This commit is contained in:
28
db_test.ts
28
db_test.ts
@@ -1,5 +1,5 @@
|
||||
import { assertEquals } from "std/testing/asserts.ts";
|
||||
import { EhDb, GMeta, PMeta } from "./db.ts";
|
||||
import { EhDb, EhFile, GMeta, PMeta } from "./db.ts";
|
||||
import { TaskType } from "./task.ts";
|
||||
import { remove_if_exists } from "./test_base.ts";
|
||||
import { sure_dir } from "./utils.ts";
|
||||
@@ -54,5 +54,31 @@ Deno.test("DbTest", async () => {
|
||||
const tags = new Set(["std", "df2", "ef3"]);
|
||||
await db.add_gtag(1, tags);
|
||||
assertEquals(tags, db.get_gtags(1));
|
||||
const f: EhFile = {
|
||||
id: 0,
|
||||
gid: 1,
|
||||
token: "s",
|
||||
path: "a.png",
|
||||
width: 1280,
|
||||
height: 720,
|
||||
is_original: true,
|
||||
};
|
||||
const f2 = db.add_file(f);
|
||||
f.id = f2.id;
|
||||
assertEquals(f, f2);
|
||||
f.path = "df.png";
|
||||
f.id = 0;
|
||||
const f3 = db.add_file(f);
|
||||
f.id = f2.id;
|
||||
assertEquals(f, f3);
|
||||
f3.path = "s.ppp";
|
||||
f3.id = 0;
|
||||
const f4 = db.add_file(f3, false);
|
||||
f3.id = f4.id;
|
||||
assertEquals(f3, f4);
|
||||
assertEquals(f.id, f2.id);
|
||||
assertEquals(db.get_files(1, "s").length, 2);
|
||||
db.add_file(f3);
|
||||
assertEquals(db.get_files(1, "s").length, 1);
|
||||
db.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user