diff --git a/libraries/deno-process-mod.test.ts b/libraries/deno-process-mod.test.ts new file mode 100644 index 0000000..1778f0e --- /dev/null +++ b/libraries/deno-process-mod.test.ts @@ -0,0 +1,42 @@ +import {assertEquals} from "jsr:@std/assert"; +import {assert} from "jsr:@std/assert/assert"; +import {parseProcessLine} from "./deno-process-mod.ts"; + +Deno.test("parseProcessLine", () => { + const p1 = parseProcessLine( + "app 3622 0.2 24.0 2932504 453004 ? Sl Jan25 23:04 /usr/lib/jvm/jdk-25/bin/java -Dfastjson.parser.safeMode=true......", + ); + if (p1 !== null) { + assertEquals("app", p1.user); + assertEquals(3622, p1.pid); + } else { + assert(false); + } + const p2 = parseProcessLine( + "root 10880 0.0 0.0 151104 1820 pts/2 R+ 23:17 0:00 ps aux", + ); + if (p2 !== null) { + assertEquals("root", p2.user); + assertEquals(10880, p2.pid); + } else { + assert(false); + } + const p3 = parseProcessLine( + "root 18 0.0 0.0 0 0 ? S< 2020 0:00 [kblockd]", + ); + if (p3 !== null) { + assertEquals("root", p3.user); + assertEquals(18, p3.pid); + } else { + assert(false); + } + const p4 = parseProcessLine( + "filebro+ 10377 0.0 0.6 1901492 12432 ? Sl 2024 25:15 /home/filebrowser/filebrowser", + ); + if (p4 !== null) { + assertEquals("filebro+", p4.user); + assertEquals(10377, p4.pid); + } else { + assert(false); + } +}); diff --git a/libraries/deno-process-mod.ts b/libraries/deno-process-mod.ts index 1e12dc7..e0e80f1 100644 --- a/libraries/deno-process-mod.ts +++ b/libraries/deno-process-mod.ts @@ -1,6 +1,3 @@ -import {assertEquals} from "jsr:@std/assert"; -import {assert} from "jsr:@std/assert/assert"; - export class Process { user: string; pid: number; @@ -74,42 +71,3 @@ export function parseProcessLine(line: string): Process | null { command, ); } - -Deno.test("parseProcessLine", () => { - const p1 = parseProcessLine( - "app 3622 0.2 24.0 2932504 453004 ? Sl Jan25 23:04 /usr/lib/jvm/jdk-25/bin/java -Dfastjson.parser.safeMode=true......", - ); - if (p1 !== null) { - assertEquals("app", p1.user); - assertEquals(3622, p1.pid); - } else { - assert(false); - } - const p2 = parseProcessLine( - "root 10880 0.0 0.0 151104 1820 pts/2 R+ 23:17 0:00 ps aux", - ); - if (p2 !== null) { - assertEquals("root", p2.user); - assertEquals(10880, p2.pid); - } else { - assert(false); - } - const p3 = parseProcessLine( - "root 18 0.0 0.0 0 0 ? S< 2020 0:00 [kblockd]", - ); - if (p3 !== null) { - assertEquals("root", p3.user); - assertEquals(18, p3.pid); - } else { - assert(false); - } - const p4 = parseProcessLine( - "filebro+ 10377 0.0 0.6 1901492 12432 ? Sl 2024 25:15 /home/filebrowser/filebrowser", - ); - if (p4 !== null) { - assertEquals("filebro+", p4.user); - assertEquals(10377, p4.pid); - } else { - assert(false); - } -}); diff --git a/libraries/deno-teencrypt-mod.test.ts b/libraries/deno-teencrypt-mod.test.ts new file mode 100644 index 0000000..fba4294 --- /dev/null +++ b/libraries/deno-teencrypt-mod.test.ts @@ -0,0 +1,11 @@ +import {assertEquals} from "jsr:@std/assert"; +import {teDecryptToString, teEncrypt} from "./deno-teencrypt-mod.ts"; + +Deno.test("teEncryptDecrypt", async () => { + assertEquals( + "hello world", + await teDecryptToString( + await teEncrypt("hello world"), + ), + ); +}); diff --git a/libraries/deno-teencrypt-mod.ts b/libraries/deno-teencrypt-mod.ts index 4937682..e0c0aae 100644 --- a/libraries/deno-teencrypt-mod.ts +++ b/libraries/deno-teencrypt-mod.ts @@ -5,7 +5,6 @@ import { resolveFilename, } from "https://global.hatter.ink/script/get/@10/deno-commons-mod.ts"; import {getRandomValues} from "node:crypto"; -import {assertEquals} from "jsr:@std/assert"; const COMMONS_LOCAL_ENCRYPT_TINY_ENCRYPT_MASTER_KEY_FILE = resolveFilename( "~/.cache/commons-local-encrypt-tiny-encrypt-master-key", @@ -105,12 +104,3 @@ function randomNonce(): ArrayBufferLike { getRandomValues(buffer); return buffer; } - -Deno.test("teEncryptDecrypt", async () => { - assertEquals( - "hello world", - await teDecryptToString( - await teEncrypt("hello world"), - ), - ); -});