From dbc89dc8d30a4aaaecea5da5f56d933918e5de6e Mon Sep 17 00:00:00 2001 From: oliver-oloughlin Date: Wed, 14 Feb 2024 02:03:03 +0100 Subject: [PATCH 1/2] feat: prefer deno.json imports over deps.ts --- deno.json | 11 ++ deno.lock | 110 +++++++++++----- ext/zod.ts | 4 +- src/atomic_builder.ts | 2 +- src/collection.ts | 6 +- src/deps.ts | 7 -- src/kvdex.ts | 2 +- src/types.ts | 2 +- src/utils.ts | 8 +- tests/collection/add.test.ts | 3 +- tests/collection/addMany.test.ts | 2 +- tests/collection/count.test.ts | 2 +- tests/collection/delete.test.ts | 2 +- tests/collection/deleteMany.test.ts | 2 +- tests/collection/enqueue.test.ts | 2 +- tests/collection/find.test.ts | 2 +- tests/collection/findMany.test.ts | 2 +- tests/collection/forEach.test.ts | 2 +- tests/collection/getMany.test.ts | 2 +- tests/collection/getOne.test.ts | 2 +- tests/collection/history.test.ts | 2 +- tests/collection/listenQueue.test.ts | 2 +- tests/collection/map.test.ts | 2 +- tests/collection/properties.test.ts | 2 +- tests/collection/set.test.ts | 2 +- tests/collection/types.test.ts | 2 +- tests/collection/update.test.ts | 3 +- tests/collection/updateMany.test.ts | 3 +- tests/collection/updateOne.test.ts | 4 +- tests/collection/upsert.test.ts | 2 +- tests/collection/watch.test.ts | 117 +++++++++--------- tests/collection/watchMany.test.ts | 113 +++++++++-------- tests/db/atomic.test.ts | 2 +- tests/db/countAll.test.ts | 2 +- tests/db/deleteAll.test.ts | 2 +- tests/db/enqueue.test.ts | 2 +- tests/db/indexable_atomic.test.ts | 2 +- tests/db/kvdex.test.ts | 2 +- tests/db/listenQueue.test.ts | 2 +- tests/db/loop.test.ts | 2 +- tests/db/setInterval.test.ts | 2 +- tests/db/wipe.test.ts | 2 +- tests/deps.ts | 5 - tests/document/flat.test.ts | 2 +- tests/document/properties.test.ts | 3 +- tests/ext/zod.test.ts | 3 +- tests/indexable_collection/add.test.ts | 2 +- tests/indexable_collection/addMany.test.ts | 2 +- tests/indexable_collection/count.test.ts | 2 +- .../countBySecondaryIndex.test.ts | 2 +- tests/indexable_collection/delete.test.ts | 2 +- .../deleteByPrimaryIndex.test.ts | 2 +- .../deleteBySecondaryIndex.test.ts | 2 +- tests/indexable_collection/deleteMany.test.ts | 2 +- tests/indexable_collection/enqueue.test.ts | 2 +- tests/indexable_collection/find.test.ts | 2 +- .../findByPrimaryIndex.test.ts | 2 +- .../findBySecondaryIndex.test.ts | 2 +- tests/indexable_collection/findMany.test.ts | 2 +- tests/indexable_collection/forEach.test.ts | 2 +- .../forEachBySecondaryIndex.test.ts | 2 +- tests/indexable_collection/getMany.test.ts | 2 +- tests/indexable_collection/getOne.test.ts | 2 +- .../getOneBySecondaryIndex.test.ts | 2 +- tests/indexable_collection/history.test.ts | 2 +- .../indexable_collection/listenQueue.test.ts | 2 +- tests/indexable_collection/map.test.ts | 2 +- .../mapBySecondaryIndex.test.ts | 2 +- tests/indexable_collection/properties.test.ts | 2 +- tests/indexable_collection/set.test.ts | 2 +- tests/indexable_collection/update.test.ts | 2 +- .../updateByPrimaryIndex.test.ts | 2 +- .../updateBySecondaryIndex.test.ts | 2 +- tests/indexable_collection/updateMany.test.ts | 2 +- tests/indexable_collection/updateOne.test.ts | 2 +- .../updateOneBySecondaryIndex.test.ts | 2 +- tests/indexable_collection/upsert.test.ts | 2 +- .../upsertByPrimaryIndex.test.ts | 2 +- tests/indexable_collection/watch.test.ts | 117 +++++++++--------- tests/indexable_collection/watchMany.test.ts | 115 +++++++++-------- tests/models.ts | 2 +- tests/serialized_collection/add.test.ts | 2 +- tests/serialized_collection/addMany.test.ts | 2 +- tests/serialized_collection/count.test.ts | 2 +- tests/serialized_collection/delete.test.ts | 2 +- .../serialized_collection/deleteMany.test.ts | 2 +- tests/serialized_collection/enqueue.test.ts | 2 +- tests/serialized_collection/find.test.ts | 2 +- tests/serialized_collection/findMany.test.ts | 2 +- tests/serialized_collection/forEach.test.ts | 2 +- tests/serialized_collection/getMany.test.ts | 2 +- tests/serialized_collection/getOne.test.ts | 2 +- tests/serialized_collection/history.test.ts | 2 +- .../serialized_collection/listenQueue.test.ts | 2 +- tests/serialized_collection/map.test.ts | 2 +- .../serialized_collection/properties.test.ts | 2 +- tests/serialized_collection/set.test.ts | 2 +- tests/serialized_collection/types.test.ts | 2 +- tests/serialized_collection/update.test.ts | 3 +- .../serialized_collection/updateMany.test.ts | 3 +- tests/serialized_collection/updateOne.test.ts | 4 +- tests/serialized_collection/upsert.test.ts | 2 +- tests/serialized_collection/watch.test.ts | 117 +++++++++--------- tests/serialized_collection/watchMany.test.ts | 10 +- .../add.test.ts | 2 +- .../addMany.test.ts | 2 +- .../count.test.ts | 2 +- .../countBySecondaryIndex.test.ts | 2 +- .../delete.test.ts | 2 +- .../deleteByPrimaryIndex.test.ts | 2 +- .../deleteBySecondaryIndex.test.ts | 2 +- .../deleteMany.test.ts | 2 +- .../enqueue.test.ts | 2 +- .../find.test.ts | 2 +- .../findByPrimaryIndex.test.ts | 2 +- .../findBySecondaryIndex.test.ts | 2 +- .../findMany.test.ts | 2 +- .../forEach.test.ts | 2 +- .../forEachBySecondaryIndex.test.ts | 2 +- .../getMany.test.ts | 2 +- .../getOne.test.ts | 2 +- .../getOneBySecondaryIndex.test.ts | 2 +- .../history.test.ts | 2 +- .../listenQueue.test.ts | 2 +- .../map.test.ts | 2 +- .../mapBySecondaryIndex.test.ts | 2 +- .../properties.test.ts | 2 +- .../set.test.ts | 2 +- .../update.test.ts | 2 +- .../updateByPrimaryIndex.test.ts | 2 +- .../updateBySecondaryIndex.test.ts | 2 +- .../updateMany.test.ts | 2 +- .../updateOne.test.ts | 2 +- .../updateOneBySecondaryIndex.test.ts | 2 +- .../upsert.test.ts | 2 +- .../upsertByPrimaryIndex.test.ts | 2 +- .../watch.test.ts | 117 +++++++++--------- .../watchMany.test.ts | 115 +++++++++-------- tests/utils/coreSerialize.test.ts | 2 +- tests/utils/denoCoreDeserialize.test.ts | 2 +- tests/utils/isKvObject.test.ts | 2 +- tests/utils/jsonDeserialize.test.ts | 2 +- tests/utils/jsonSerialize.test.ts | 2 +- 143 files changed, 649 insertions(+), 590 deletions(-) delete mode 100644 src/deps.ts delete mode 100644 tests/deps.ts diff --git a/deno.json b/deno.json index fa4ead8..2e12a42 100644 --- a/deno.json +++ b/deno.json @@ -5,6 +5,17 @@ ".": "./mod.ts", "./ext/zod": "./ext/zod.ts" }, + "imports": { + "assert": "jsr:@std/assert@0.215", + "assert_equals": "jsr:@std/assert@0.215/assert_equals", + "assert_not_equals": "jsr:@std/assert@0.215/assert_not_equals", + "assert_throws": "jsr:@std/assert@0.215/assert_throws", + "ulid": "jsr:@std/ulid@0.215", + "concat": "jsr:@std/bytes@0.215/concat", + "deep_merge": "jsr:@std/collections@0.215/deep_merge", + "zlib": "node:zlib", + "zod": "npm:zod@3" + }, "tasks": { "check": "deno check mod.ts src/*.ts ext/*.ts tests/*.ts tests/**/*.ts benchmarks/**/*ts", "test": "deno test --allow-write --allow-read --unstable-kv --trace-ops", diff --git a/deno.lock b/deno.lock index 7505071..1c2a96f 100644 --- a/deno.lock +++ b/deno.lock @@ -2,25 +2,47 @@ "version": "3", "packages": { "specifiers": { - "jsr:@std/assert@0.214.0": "jsr:@std/assert@0.214.0", - "jsr:@std/bytes@0.214.0": "jsr:@std/bytes@0.214.0", - "jsr:@std/collections@0.214.0": "jsr:@std/collections@0.214.0", - "jsr:@std/fmt@^0.214.0": "jsr:@std/fmt@0.214.0", - "jsr:@std/ulid@0.214.0": "jsr:@std/ulid@0.214.0", - "npm:zod@3.22.4": "npm:zod@3.22.4" + "jsr:@std/assert@0.215": "jsr:@std/assert@0.215.0", + "jsr:@std/bytes@0.215": "jsr:@std/bytes@0.215.0", + "jsr:@std/collections@0.215": "jsr:@std/collections@0.215.0", + "jsr:@std/fmt@^0.215.0": "jsr:@std/fmt@0.215.0", + "jsr:@std/ulid@0.215": "jsr:@std/ulid@0.215.0", + "npm:@types/node": "npm:@types/node@18.16.19", + "npm:superjson@1.13.3": "npm:superjson@1.13.3", + "npm:zod@3": "npm:zod@3.22.4" }, "jsr": { - "@std/assert@0.214.0": { + "@std/assert@0.215.0": { "dependencies": [ - "jsr:@std/fmt@^0.214.0" + "jsr:@std/fmt@^0.215.0" ] }, - "@std/bytes@0.214.0": {}, - "@std/collections@0.214.0": {}, - "@std/fmt@0.214.0": {}, - "@std/ulid@0.214.0": {} + "@std/bytes@0.215.0": {}, + "@std/collections@0.215.0": {}, + "@std/fmt@0.215.0": {}, + "@std/ulid@0.215.0": {} }, "npm": { + "@types/node@18.16.19": { + "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", + "dependencies": {} + }, + "copy-anything@3.0.5": { + "integrity": "sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==", + "dependencies": { + "is-what": "is-what@4.1.16" + } + }, + "is-what@4.1.16": { + "integrity": "sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==", + "dependencies": {} + }, + "superjson@1.13.3": { + "integrity": "sha512-mJiVjfd2vokfDxsQPOwJ/PtanO87LhpYY88ubI5dUB1Ab58Txbyje3+jpm+/83R/fevaq/107NNhtYBLuoTrFg==", + "dependencies": { + "copy-anything": "copy-anything@3.0.5" + } + }, "zod@3.22.4": { "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==", "dependencies": {} @@ -28,21 +50,53 @@ } }, "remote": { - "https://jsr.io/@std/assert/0.214.0/_constants.ts": "a271e8ef5a573f1df8e822a6eb9d09df064ad66a4390f21b3e31f820a38e0975", - "https://jsr.io/@std/assert/0.214.0/_diff.ts": "dbacca10c0e1acb3da9b6a90bec50c7d1add05deb5abe9614a3784c9d5a0b887", - "https://jsr.io/@std/assert/0.214.0/_format.ts": "0ba808961bf678437fb486b56405b6fefad2cf87b5809667c781ddee8c32aff4", - "https://jsr.io/@std/assert/0.214.0/assert.ts": "501b416473ec27c71885aaf819e363c8df617f89ce68ae57fec7acf9d62743b2", - "https://jsr.io/@std/assert/0.214.0/assert_equals.ts": "9c0bacb975b890237b7515583685b5dcd056f86ffe096891e00e052e2ceced06", - "https://jsr.io/@std/assert/0.214.0/assert_is_error.ts": "670ede152be91756cf1012dd07ea3965d7c4f780fba6e88ed088cf4f88f5b91e", - "https://jsr.io/@std/assert/0.214.0/assert_not_equals.ts": "b08ac1034e4b9aedff0bad798df7880c8f977019a90e98a5e0e4f88c7dfa6353", - "https://jsr.io/@std/assert/0.214.0/assert_throws.ts": "4209628c4fa3e569bb2924b289fad486f9e5feb0912bca6f60b484ddbfad7136", - "https://jsr.io/@std/assert/0.214.0/assertion_error.ts": "dd027fb33707dbff22cd2ef9b55fdb70e2095876caf3c68ecfbb811505ecc022", - "https://jsr.io/@std/assert/0.214.0/equal.ts": "166d9377ce8df4d53f676d9a568a13914c2323d9d3b2fd1096aafeb59f3c1edf", - "https://jsr.io/@std/bytes/0.214.0/concat.ts": "8142a1734fd445582be0d209d0def43c2a3c27370a0fd4b327187dd34b98d6eb", - "https://jsr.io/@std/collections/0.214.0/_utils.ts": "fc59674548a4dd9f5c3cc4f99f9c264aa521a52c1a4ff56b0263713e57e79206", - "https://jsr.io/@std/collections/0.214.0/deep_merge.ts": "23863106aa1ac392347204fc4d234addee9788d54c89174cf1d841541a320895", - "https://jsr.io/@std/fmt/0.214.0/colors.ts": "59b5de7c07cdc0322ed61b2d98da1ca4fbc9f576d45c2beee577a27556e52d63", - "https://jsr.io/@std/ulid/0.214.0/_util.ts": "27b0b5d69ab6e98406c75e85381e2dfd0b0c128b891f122a37ff2adda782e35b", - "https://jsr.io/@std/ulid/0.214.0/mod.ts": "35bb29e54c711911f7cf984117373b0fdb2ba77d32561eea2530462138a6bb4d" + "https://deno.land/std@0.203.0/dotenv/load.ts": "0636983549b98f29ab75c9a22a42d9723f0a389ece5498fe971e7bb2556a12e2", + "https://deno.land/std@0.203.0/dotenv/mod.ts": "1da8c6d0e7f7d8a5c2b19400b763bc11739df24acec235dda7ea2cfd3d300057", + "https://jsr.io/@std/assert/0.215.0/_constants.ts": "a271e8ef5a573f1df8e822a6eb9d09df064ad66a4390f21b3e31f820a38e0975", + "https://jsr.io/@std/assert/0.215.0/_diff.ts": "f8f568f6d3a36652deb4701303fe7a2a66bfec242682effe53211398e363c39e", + "https://jsr.io/@std/assert/0.215.0/_format.ts": "0ba808961bf678437fb486b56405b6fefad2cf87b5809667c781ddee8c32aff4", + "https://jsr.io/@std/assert/0.215.0/assert.ts": "501b416473ec27c71885aaf819e363c8df617f89ce68ae57fec7acf9d62743b2", + "https://jsr.io/@std/assert/0.215.0/assert_almost_equals.ts": "77a20a203abff37146dc029afd14e7cce9c9c085c25a107a5f075ed49b646db0", + "https://jsr.io/@std/assert/0.215.0/assert_array_includes.ts": "9f511b9b57d48f1ff643259192a66f855b8075a8fb9d9f3cdefc0e008cfe3466", + "https://jsr.io/@std/assert/0.215.0/assert_equals.ts": "78139785a690be8e450ad13698287bfb5c50518833a6c4ccb96d6fe66dd9c573", + "https://jsr.io/@std/assert/0.215.0/assert_exists.ts": "7ea6a5cbaf3ce2675adc863d11544ba0f0d6e61658c5f0a83b5aa999e48961f0", + "https://jsr.io/@std/assert/0.215.0/assert_false.ts": "8941f89de0386609eb1749f334483d56420307997bbbba77a559c5fe7083a657", + "https://jsr.io/@std/assert/0.215.0/assert_greater.ts": "441cfcab6ab8c06d6c54d5995d513a148c9ed7ec2d241c154e6a127b3f22f995", + "https://jsr.io/@std/assert/0.215.0/assert_greater_or_equal.ts": "d841652741b8087235f3392abd6db387cc4ecfe91cbd9fbc721937789f325faa", + "https://jsr.io/@std/assert/0.215.0/assert_instance_of.ts": "ab945d09a94ca382ac4e9044412a9414efe301ad0ae36b72c02159e7148321ed", + "https://jsr.io/@std/assert/0.215.0/assert_is_error.ts": "823298a6a5bf5e51580932aadbb1cfb22a6945c502868dc9dca2a70bcf70062d", + "https://jsr.io/@std/assert/0.215.0/assert_less.ts": "282d39e91ce16e33d5b8352771d97c81d840f1810ba7b65b64332eba5b0f0c50", + "https://jsr.io/@std/assert/0.215.0/assert_less_or_equal.ts": "a68b8ae9fa056449b63c8d3fb771fe8a3747d958877096e85839b75f3c581576", + "https://jsr.io/@std/assert/0.215.0/assert_match.ts": "7395d0d84346d9a81695559d11afe890137f1c469bb5cafb6aba1a7faaf142f8", + "https://jsr.io/@std/assert/0.215.0/assert_not_equals.ts": "b08ac1034e4b9aedff0bad798df7880c8f977019a90e98a5e0e4f88c7dfa6353", + "https://jsr.io/@std/assert/0.215.0/assert_not_instance_of.ts": "340861128c5a03071247fdc6011b8499fd277d9faeb14306a4af9cd642a302c3", + "https://jsr.io/@std/assert/0.215.0/assert_not_match.ts": "f09d94377a6403800f7d8602a70bce27d3d6ff699cd95e141b43c35c3b0e798d", + "https://jsr.io/@std/assert/0.215.0/assert_not_strict_equals.ts": "1028e690746157783c44cd0d17d88d17a57ece9d387a8cc8e15aef291ac98258", + "https://jsr.io/@std/assert/0.215.0/assert_object_match.ts": "9f02fd409595a8b656ec9f436fe012932e3729a58e8292e7c4c5b9b50266da5f", + "https://jsr.io/@std/assert/0.215.0/assert_rejects.ts": "af2d87faafdf44a3af69fd9e8952d5a07707d2b6b8c413f46ec3b90227539b3a", + "https://jsr.io/@std/assert/0.215.0/assert_strict_equals.ts": "72d7b15c9cf128cd4fbb29fb794e1a2bc612b55935de035f17127587f8411e75", + "https://jsr.io/@std/assert/0.215.0/assert_string_includes.ts": "c178bd97da03e2215494e729b2048ae68e780bf0b583a998a3bf808fbdb1eba2", + "https://jsr.io/@std/assert/0.215.0/assert_throws.ts": "4209628c4fa3e569bb2924b289fad486f9e5feb0912bca6f60b484ddbfad7136", + "https://jsr.io/@std/assert/0.215.0/assertion_error.ts": "dd027fb33707dbff22cd2ef9b55fdb70e2095876caf3c68ecfbb811505ecc022", + "https://jsr.io/@std/assert/0.215.0/equal.ts": "166d9377ce8df4d53f676d9a568a13914c2323d9d3b2fd1096aafeb59f3c1edf", + "https://jsr.io/@std/assert/0.215.0/fail.ts": "67579a1308b176d52756ded6d1e3149f87703648e59afc333ba5168fefeb8d7b", + "https://jsr.io/@std/assert/0.215.0/mod.ts": "325df8c0683ad83a873b9691aa66b812d6275fc9fec0b2d180ac68a2c5efed3b", + "https://jsr.io/@std/assert/0.215.0/unimplemented.ts": "ed3115f6fb271277e0522f3b18f020259900c385e3fa986f109a519a1cf25763", + "https://jsr.io/@std/assert/0.215.0/unreachable.ts": "1e748f69f73c57f4de9ba1dba39306b86e0ad2c0915975608519a2bcf42c262f", + "https://jsr.io/@std/bytes/0.215.0/concat.ts": "8142a1734fd445582be0d209d0def43c2a3c27370a0fd4b327187dd34b98d6eb", + "https://jsr.io/@std/collections/0.215.0/_utils.ts": "fc59674548a4dd9f5c3cc4f99f9c264aa521a52c1a4ff56b0263713e57e79206", + "https://jsr.io/@std/collections/0.215.0/deep_merge.ts": "23863106aa1ac392347204fc4d234addee9788d54c89174cf1d841541a320895", + "https://jsr.io/@std/fmt/0.215.0/colors.ts": "59b5de7c07cdc0322ed61b2d98da1ca4fbc9f576d45c2beee577a27556e52d63", + "https://jsr.io/@std/ulid/0.215.0/_util.ts": "27b0b5d69ab6e98406c75e85381e2dfd0b0c128b891f122a37ff2adda782e35b", + "https://jsr.io/@std/ulid/0.215.0/mod.ts": "35bb29e54c711911f7cf984117373b0fdb2ba77d32561eea2530462138a6bb4d" + }, + "workspace": { + "dependencies": [ + "jsr:@std/assert@0.215", + "jsr:@std/bytes@0.215", + "jsr:@std/collections@0.215", + "jsr:@std/ulid@0.215", + "npm:zod@3" + ] } } diff --git a/ext/zod.ts b/ext/zod.ts index d3250a0..d6e0893 100644 --- a/ext/zod.ts +++ b/ext/zod.ts @@ -1,5 +1,5 @@ -import { z } from "npm:zod@3.22.4" -import type { KvArray, KvId, KvObject, KvValue, Model } from "../mod.ts" +import { z } from "zod" +import type { KvArray, KvId, KvObject, KvValue, Model } from "../src/types.ts" /*******************/ /* */ diff --git a/src/atomic_builder.ts b/src/atomic_builder.ts index 002bda5..a84239f 100644 --- a/src/atomic_builder.ts +++ b/src/atomic_builder.ts @@ -1,5 +1,5 @@ import type { Collection } from "./collection.ts" -import { ulid } from "./deps.ts" +import { ulid } from "ulid" import { InvalidCollectionError } from "./errors.ts" import type { AtomicCheck, diff --git a/src/collection.ts b/src/collection.ts index 6f24cfb..abd6cc4 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -1,5 +1,6 @@ import type { AtomicListOptions, + BuilderFn, CheckKeyOf, CollectionKeys, CollectionOptions, @@ -78,8 +79,9 @@ import { AtomicWrapper } from "./atomic_wrapper.ts" import { AtomicPool } from "./atomic_pool.ts" import { Document } from "./document.ts" import { model } from "./model.ts" -import { concat, deepMerge, ulid } from "./deps.ts" -import { BuilderFn } from "./types.ts" +import { concat } from "concat" +import { deepMerge } from "deep_merge" +import { ulid } from "ulid" /** * Create a new collection within a database context. diff --git a/src/deps.ts b/src/deps.ts deleted file mode 100644 index e706626..0000000 --- a/src/deps.ts +++ /dev/null @@ -1,7 +0,0 @@ -export { brotliCompressSync, brotliDecompressSync, constants } from "node:zlib" -export { - deepMerge, - type DeepMergeOptions, -} from "jsr:@std/collections@0.214.0/deep_merge" -export { concat } from "jsr:@std/bytes@0.214.0/concat" -export { ulid } from "jsr:@std/ulid@0.214.0" diff --git a/src/kvdex.ts b/src/kvdex.ts index 5834594..ca4c730 100644 --- a/src/kvdex.ts +++ b/src/kvdex.ts @@ -5,6 +5,7 @@ import type { EnqueueOptions, FindOptions, IntervalMessage, + IntervalSetter, KvId, KvKey, KvValue, @@ -36,7 +37,6 @@ import { } from "./constants.ts" import { model } from "./model.ts" import { AtomicWrapper } from "./atomic_wrapper.ts" -import { IntervalSetter } from "./types.ts" /** * Create a new database instance. diff --git a/src/types.ts b/src/types.ts index 46ef1ca..4037ea3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ import type { Collection } from "./collection.ts" -import type { DeepMergeOptions } from "./deps.ts" +import type { DeepMergeOptions } from "deep_merge" import type { Document } from "./document.ts" /*********************/ diff --git a/src/utils.ts b/src/utils.ts index f225bd5..6f2baff 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -15,12 +15,8 @@ import type { PreparedEnqueue, QueueMessage, } from "./types.ts" -import { - brotliCompressSync, - brotliDecompressSync, - constants, - ulid, -} from "./deps.ts" +import { brotliCompressSync, brotliDecompressSync, constants } from "zlib" +import { ulid } from "ulid" /*************************/ /* */ diff --git a/tests/collection/add.test.ts b/tests/collection/add.test.ts index f740505..803f70e 100644 --- a/tests/collection/add.test.ts +++ b/tests/collection/add.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUserInvalid } from "../mocks.ts" import { useDb } from "../utils.ts" @@ -22,6 +22,7 @@ Deno.test("collection - add", async (t) => { assert(cr.ok) const doc = await db.z_users.find(cr.id) + assert(doc !== null) assert(doc.value.username === mockUser1.username) }) diff --git a/tests/collection/addMany.test.ts b/tests/collection/addMany.test.ts index 88d0604..45e5ceb 100644 --- a/tests/collection/addMany.test.ts +++ b/tests/collection/addMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateInvalidUsers, generateUsers, useDb } from "../utils.ts" Deno.test("collection - addMany", async (t) => { diff --git a/tests/collection/count.test.ts b/tests/collection/count.test.ts index 55d7bd1..054e3d9 100644 --- a/tests/collection/count.test.ts +++ b/tests/collection/count.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/collection/delete.test.ts b/tests/collection/delete.test.ts index cb3884b..d79009a 100644 --- a/tests/collection/delete.test.ts +++ b/tests/collection/delete.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { generateUsers, useDb } from "../utils.ts" diff --git a/tests/collection/deleteMany.test.ts b/tests/collection/deleteMany.test.ts index 3310f5d..c72e234 100644 --- a/tests/collection/deleteMany.test.ts +++ b/tests/collection/deleteMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers, useDb } from "../utils.ts" Deno.test("collection - deleteMany", async (t) => { diff --git a/tests/collection/enqueue.test.ts b/tests/collection/enqueue.test.ts index e7bd8d1..c0cec48 100644 --- a/tests/collection/enqueue.test.ts +++ b/tests/collection/enqueue.test.ts @@ -1,6 +1,6 @@ import { collection, kvdex, KvValue, model, QueueMessage } from "../../mod.ts" import { createHandlerId } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { createResolver, useDb, useKv } from "../utils.ts" Deno.test("collection - enqueue", async (t) => { diff --git a/tests/collection/find.test.ts b/tests/collection/find.test.ts index 0e93d6a..7624186 100644 --- a/tests/collection/find.test.ts +++ b/tests/collection/find.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/collection/findMany.test.ts b/tests/collection/findMany.test.ts index bb91ecb..3601080 100644 --- a/tests/collection/findMany.test.ts +++ b/tests/collection/findMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers, useDb } from "../utils.ts" Deno.test("collection - findMany", async (t) => { diff --git a/tests/collection/forEach.test.ts b/tests/collection/forEach.test.ts index b68e208..a8195ca 100644 --- a/tests/collection/forEach.test.ts +++ b/tests/collection/forEach.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { generateUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/collection/getMany.test.ts b/tests/collection/getMany.test.ts index 90eb1de..30146ed 100644 --- a/tests/collection/getMany.test.ts +++ b/tests/collection/getMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/collection/getOne.test.ts b/tests/collection/getOne.test.ts index 313a634..8f7b929 100644 --- a/tests/collection/getOne.test.ts +++ b/tests/collection/getOne.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { sleep, useDb } from "../utils.ts" import { mockUser1, mockUser2 } from "../mocks.ts" diff --git a/tests/collection/history.test.ts b/tests/collection/history.test.ts index f4783de..e6a5f0c 100644 --- a/tests/collection/history.test.ts +++ b/tests/collection/history.test.ts @@ -1,5 +1,5 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { sleep, useKv } from "../utils.ts" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import type { User } from "../models.ts" diff --git a/tests/collection/listenQueue.test.ts b/tests/collection/listenQueue.test.ts index 83d2b0d..c567121 100644 --- a/tests/collection/listenQueue.test.ts +++ b/tests/collection/listenQueue.test.ts @@ -4,7 +4,7 @@ import { UNDELIVERED_KEY_PREFIX, } from "../../src/constants.ts" import { createHandlerId, extendKey } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { createResolver, sleep, useKv } from "../utils.ts" Deno.test("collection - listenQueue", async (t) => { diff --git a/tests/collection/map.test.ts b/tests/collection/map.test.ts index 676c86f..cc44a7e 100644 --- a/tests/collection/map.test.ts +++ b/tests/collection/map.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/collection/properties.test.ts b/tests/collection/properties.test.ts index 7b60e47..a5ae512 100644 --- a/tests/collection/properties.test.ts +++ b/tests/collection/properties.test.ts @@ -1,7 +1,7 @@ import { collection, Document, kvdex, model } from "../../mod.ts" import { ID_KEY_PREFIX, KVDEX_KEY_PREFIX } from "../../src/constants.ts" import { extendKey, keyEq } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { User } from "../models.ts" import { generateUsers, useDb, useKv } from "../utils.ts" diff --git a/tests/collection/set.test.ts b/tests/collection/set.test.ts index 7fa3298..2ea82f9 100644 --- a/tests/collection/set.test.ts +++ b/tests/collection/set.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/collection/types.test.ts b/tests/collection/types.test.ts index 12b9a8a..27a0f65 100644 --- a/tests/collection/types.test.ts +++ b/tests/collection/types.test.ts @@ -1,5 +1,5 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { useKv } from "../utils.ts" Deno.test("collection - types", async (t) => { diff --git a/tests/collection/update.test.ts b/tests/collection/update.test.ts index 03e3839..0ca4f6b 100644 --- a/tests/collection/update.test.ts +++ b/tests/collection/update.test.ts @@ -1,5 +1,6 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert, assertEquals } from "../deps.ts" +import { assertEquals } from "assert_equals" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { useDb, useKv } from "../utils.ts" diff --git a/tests/collection/updateMany.test.ts b/tests/collection/updateMany.test.ts index 1f7da5e..4edac0b 100644 --- a/tests/collection/updateMany.test.ts +++ b/tests/collection/updateMany.test.ts @@ -1,5 +1,6 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert, assertEquals } from "../deps.ts" +import { assertEquals } from "assert_equals" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUserInvalid } from "../mocks.ts" import { generateNumbers, generateUsers, useDb, useKv } from "../utils.ts" diff --git a/tests/collection/updateOne.test.ts b/tests/collection/updateOne.test.ts index 38c943d..5b4fbdd 100644 --- a/tests/collection/updateOne.test.ts +++ b/tests/collection/updateOne.test.ts @@ -1,5 +1,7 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert, assertEquals, assertNotEquals } from "../deps.ts" +import { assertEquals } from "assert_equals" +import { assertNotEquals } from "assert_not_equals" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser3 } from "../mocks.ts" import { mockUser2 } from "../mocks.ts" import { mockUser1, mockUserInvalid } from "../mocks.ts" diff --git a/tests/collection/upsert.test.ts b/tests/collection/upsert.test.ts index 0c17b57..26b9507 100644 --- a/tests/collection/upsert.test.ts +++ b/tests/collection/upsert.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/collection/watch.test.ts b/tests/collection/watch.test.ts index 35653a0..7a781c4 100644 --- a/tests/collection/watch.test.ts +++ b/tests/collection/watch.test.ts @@ -1,72 +1,71 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { sleep, useDb } from "../utils.ts" -Deno.test({ - name: "collection - watch", - sanitizeResources: false, - sanitizeOps: false, - fn: async (t) => { - await t.step("Should receive all document updates", async () => { - await useDb(async (db) => { - const id = "id" - let count = 0 - let username = "" - let lastDoc: any +Deno.test("collection - watch", async (t) => { + await t.step("Should receive all document updates", async () => { + await useDb(async (db) => { + const id = "id" + let count = 0 + let username = "" + let lastDoc: any - db.users.watch(id, (doc) => { - count++ - lastDoc = doc - if (doc?.value.username) { - username = doc.value.username - } - }) + const watcher = db.users.watch(id, (doc) => { + count++ + lastDoc = doc + if (doc?.value.username) { + username = doc.value.username + } + }) - await db.users.set(id, mockUser1) - await sleep(500) - await db.users.set(id, mockUser2, { overwrite: true }) - await sleep(500) - await db.users.update(id, mockUser3) - await sleep(500) - await db.users.delete(id) - await sleep(500) + await db.users.set(id, mockUser1) + await sleep(500) + await db.users.set(id, mockUser2, { overwrite: true }) + await sleep(500) + await db.users.update(id, mockUser3) + await sleep(500) + await db.users.delete(id) + await sleep(500) - assert(count === 4) - assert(username === mockUser3.username) - assert(lastDoc === null) - }) + assert(count === 4) + assert(username === mockUser3.username) + assert(lastDoc === null) + + return async () => await watcher }) + }) - await t.step("Should not receive unrelated document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id2" - let count = 0 - let username = "" - let lastDoc: any + await t.step("Should not receive unrelated document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id2" + let count = 0 + let username = "" + let lastDoc: any - db.users.watch(id1, (doc) => { - count++ - lastDoc = doc - if (doc?.value.username) { - username = doc.value.username - } - }) + const watcher = db.users.watch(id1, (doc) => { + count++ + lastDoc = doc + if (doc?.value.username) { + username = doc.value.username + } + }) - await db.users.set(id2, mockUser1) - await sleep(500) - await db.users.set(id2, mockUser2, { overwrite: true }) - await sleep(500) - await db.users.update(id2, mockUser3) - await sleep(500) - await db.users.delete(id2) - await sleep(500) + await db.users.set(id2, mockUser1) + await sleep(500) + await db.users.set(id2, mockUser2, { overwrite: true }) + await sleep(500) + await db.users.update(id2, mockUser3) + await sleep(500) + await db.users.delete(id2) + await sleep(500) - // Account for initial invocation - assert(count === 1) - assert(username === "") - assert(lastDoc === null) - }) + // Account for initial invocation + assert(count === 1) + assert(username === "") + assert(lastDoc === null) + + return async () => await watcher }) - }, + }) }) diff --git a/tests/collection/watchMany.test.ts b/tests/collection/watchMany.test.ts index d6d61ca..4a79b01 100644 --- a/tests/collection/watchMany.test.ts +++ b/tests/collection/watchMany.test.ts @@ -1,71 +1,70 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { sleep, useDb } from "../utils.ts" -Deno.test({ - name: "collection - watchMany", - sanitizeResources: false, - sanitizeOps: false, - fn: async (t) => { - await t.step("Should receive all document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id2" - const id3 = "id3" - let count = 0 - let lastDocs: any[] = [] +Deno.test("collection - watchMany", async (t) => { + await t.step("Should receive all document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id2" + const id3 = "id3" + let count = 0 + let lastDocs: any[] = [] - await db.users.set(id3, mockUser1) + await db.users.set(id3, mockUser1) - db.users.watchMany([id1, id2, id3], (docs) => { - count++ - lastDocs = docs - }) + const watcher = db.users.watchMany([id1, id2, id3], (docs) => { + count++ + lastDocs = docs + }) - await db.users.set(id1, mockUser1) - await sleep(500) - await db.users.delete(id1) - await sleep(500) - await db.users.set(id2, mockUser2, { overwrite: true }) - await sleep(500) - await db.users.update(id3, mockUser3) - await sleep(500) + await db.users.set(id1, mockUser1) + await sleep(500) + await db.users.delete(id1) + await sleep(500) + await db.users.set(id2, mockUser2, { overwrite: true }) + await sleep(500) + await db.users.update(id3, mockUser3) + await sleep(500) - assert(count === 4) - assert(lastDocs[0] === null) - assert(lastDocs[1]?.value.username === mockUser2.username) - assert(lastDocs[2]?.value.username === mockUser3.username) - }) + assert(count === 4) + assert(lastDocs[0] === null) + assert(lastDocs[1]?.value.username === mockUser2.username) + assert(lastDocs[2]?.value.username === mockUser3.username) + + return async () => await watcher }) + }) - await t.step("Should not receive unrelated document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id1" - const id3 = "id1" - const id4 = "id4" - let count = 0 - let lastDocs: any[] = [] + await t.step("Should not receive unrelated document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id1" + const id3 = "id1" + const id4 = "id4" + let count = 0 + let lastDocs: any[] = [] - db.users.watchMany([id1, id2, id3], (docs) => { - count++ - lastDocs = docs - }) + const watcher = db.users.watchMany([id1, id2, id3], (docs) => { + count++ + lastDocs = docs + }) - await db.users.set(id4, mockUser1) - await sleep(500) - await db.users.set(id4, mockUser2, { overwrite: true }) - await sleep(500) - await db.users.update(id4, mockUser3) - await sleep(500) - await db.users.delete(id4) - await sleep(500) + await db.users.set(id4, mockUser1) + await sleep(500) + await db.users.set(id4, mockUser2, { overwrite: true }) + await sleep(500) + await db.users.update(id4, mockUser3) + await sleep(500) + await db.users.delete(id4) + await sleep(500) - assert(count === 1) - assert(lastDocs[0] === null) - assert(lastDocs[1] === null) - assert(lastDocs[2] === null) - }) + assert(count === 1) + assert(lastDocs[0] === null) + assert(lastDocs[1] === null) + assert(lastDocs[2] === null) + + return async () => await watcher }) - }, + }) }) diff --git a/tests/db/atomic.test.ts b/tests/db/atomic.test.ts index 720bcdd..689dd26 100644 --- a/tests/db/atomic.test.ts +++ b/tests/db/atomic.test.ts @@ -1,6 +1,6 @@ import { collection, kvdex, KvValue, model, QueueMessage } from "../../mod.ts" import { createHandlerId } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { sleep, useDb, useKv } from "../utils.ts" diff --git a/tests/db/countAll.test.ts b/tests/db/countAll.test.ts index ae3afbd..c68354e 100644 --- a/tests/db/countAll.test.ts +++ b/tests/db/countAll.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, generateUsers, useDb } from "../utils.ts" Deno.test("db - countAll", async (t) => { diff --git a/tests/db/deleteAll.test.ts b/tests/db/deleteAll.test.ts index 6bb2972..139bdb4 100644 --- a/tests/db/deleteAll.test.ts +++ b/tests/db/deleteAll.test.ts @@ -1,5 +1,5 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { generateLargeUsers, generateUsers, useKv } from "../utils.ts" diff --git a/tests/db/enqueue.test.ts b/tests/db/enqueue.test.ts index fafe75f..2174c59 100644 --- a/tests/db/enqueue.test.ts +++ b/tests/db/enqueue.test.ts @@ -1,7 +1,7 @@ import { collection, kvdex, KvValue, model, QueueMessage } from "../../mod.ts" import { KVDEX_KEY_PREFIX } from "../../src/constants.ts" import { createHandlerId } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { createResolver, useKv } from "../utils.ts" Deno.test("db - enqueue", async (t) => { diff --git a/tests/db/indexable_atomic.test.ts b/tests/db/indexable_atomic.test.ts index a95e395..9dcbfe6 100644 --- a/tests/db/indexable_atomic.test.ts +++ b/tests/db/indexable_atomic.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/db/kvdex.test.ts b/tests/db/kvdex.test.ts index 4ab909c..aa65a81 100644 --- a/tests/db/kvdex.test.ts +++ b/tests/db/kvdex.test.ts @@ -1,6 +1,6 @@ import { collection, kvdex, model } from "../../mod.ts" import { KVDEX_KEY_PREFIX } from "../../src/constants.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { useKv } from "../utils.ts" Deno.test("db - kvdex", async (t) => { diff --git a/tests/db/listenQueue.test.ts b/tests/db/listenQueue.test.ts index 56781f3..3b275df 100644 --- a/tests/db/listenQueue.test.ts +++ b/tests/db/listenQueue.test.ts @@ -1,7 +1,7 @@ import { collection, kvdex, KvValue, model, QueueMessage } from "../../mod.ts" import { KVDEX_KEY_PREFIX } from "../../src/constants.ts" import { createHandlerId } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { createResolver, sleep, useKv } from "../utils.ts" Deno.test("db - listenQueue", async (t) => { diff --git a/tests/db/loop.test.ts b/tests/db/loop.test.ts index 2d16530..04e47fb 100644 --- a/tests/db/loop.test.ts +++ b/tests/db/loop.test.ts @@ -1,5 +1,5 @@ import { kvdex } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { createResolver, useDb, useKv } from "../utils.ts" Deno.test("db - loop", async (t) => { diff --git a/tests/db/setInterval.test.ts b/tests/db/setInterval.test.ts index 892d74c..0706f13 100644 --- a/tests/db/setInterval.test.ts +++ b/tests/db/setInterval.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { createResolver, useDb } from "../utils.ts" Deno.test("db - setInterval", async (t) => { diff --git a/tests/db/wipe.test.ts b/tests/db/wipe.test.ts index 688a6ff..803a2fd 100644 --- a/tests/db/wipe.test.ts +++ b/tests/db/wipe.test.ts @@ -1,5 +1,5 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { generateLargeUsers, generateUsers, useKv } from "../utils.ts" diff --git a/tests/deps.ts b/tests/deps.ts deleted file mode 100644 index 1d8019f..0000000 --- a/tests/deps.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { assert } from "jsr:@std/assert@0.214.0/assert" -export { assertEquals } from "jsr:@std/assert@0.214.0/assert_equals" -export { assertNotEquals } from "jsr:@std/assert@0.214.0/assert_not_equals" -export { assertThrows } from "jsr:@std/assert@0.214.0/assert_throws" -export { z } from "npm:zod@3.22.4" diff --git a/tests/document/flat.test.ts b/tests/document/flat.test.ts index f434d6f..8fbaafe 100644 --- a/tests/document/flat.test.ts +++ b/tests/document/flat.test.ts @@ -1,5 +1,5 @@ import { Document, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { User } from "../models.ts" diff --git a/tests/document/properties.test.ts b/tests/document/properties.test.ts index f755f78..c38a55d 100644 --- a/tests/document/properties.test.ts +++ b/tests/document/properties.test.ts @@ -1,5 +1,6 @@ import { Document, model } from "../../mod.ts" -import { assert, z } from "../deps.ts" +import { z } from "zod" +import { assert } from "jsr:@std/assert@0.215/assert" Deno.test("document - properties", async (t) => { await t.step("Should create document with Model", () => { diff --git a/tests/ext/zod.test.ts b/tests/ext/zod.test.ts index e0e643b..6be51a9 100644 --- a/tests/ext/zod.test.ts +++ b/tests/ext/zod.test.ts @@ -1,4 +1,5 @@ -import { assert, z } from "../deps.ts" +import { z } from "zod" +import { assert } from "jsr:@std/assert@0.215/assert" import { KvArraySchema, KvIdSchema, diff --git a/tests/indexable_collection/add.test.ts b/tests/indexable_collection/add.test.ts index 0caf841..255ad27 100644 --- a/tests/indexable_collection/add.test.ts +++ b/tests/indexable_collection/add.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUserInvalid } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/addMany.test.ts b/tests/indexable_collection/addMany.test.ts index 4ee56dc..34c613b 100644 --- a/tests/indexable_collection/addMany.test.ts +++ b/tests/indexable_collection/addMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { generateInvalidUsers, generateUsers, useDb } from "../utils.ts" diff --git a/tests/indexable_collection/count.test.ts b/tests/indexable_collection/count.test.ts index 073c461..5c100f4 100644 --- a/tests/indexable_collection/count.test.ts +++ b/tests/indexable_collection/count.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/countBySecondaryIndex.test.ts b/tests/indexable_collection/countBySecondaryIndex.test.ts index 42eefa2..610c361 100644 --- a/tests/indexable_collection/countBySecondaryIndex.test.ts +++ b/tests/indexable_collection/countBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/delete.test.ts b/tests/indexable_collection/delete.test.ts index 30d8789..031ba41 100644 --- a/tests/indexable_collection/delete.test.ts +++ b/tests/indexable_collection/delete.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { generateUsers, useDb } from "../utils.ts" diff --git a/tests/indexable_collection/deleteByPrimaryIndex.test.ts b/tests/indexable_collection/deleteByPrimaryIndex.test.ts index 67d6f0b..25a2d3c 100644 --- a/tests/indexable_collection/deleteByPrimaryIndex.test.ts +++ b/tests/indexable_collection/deleteByPrimaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/deleteBySecondaryIndex.test.ts b/tests/indexable_collection/deleteBySecondaryIndex.test.ts index 26c8279..ebcd9e1 100644 --- a/tests/indexable_collection/deleteBySecondaryIndex.test.ts +++ b/tests/indexable_collection/deleteBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/deleteMany.test.ts b/tests/indexable_collection/deleteMany.test.ts index d86ad38..777ad3f 100644 --- a/tests/indexable_collection/deleteMany.test.ts +++ b/tests/indexable_collection/deleteMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers, useDb } from "../utils.ts" Deno.test("indexable_collection - deleteMany", async (t) => { diff --git a/tests/indexable_collection/enqueue.test.ts b/tests/indexable_collection/enqueue.test.ts index 68d7a8f..120ced3 100644 --- a/tests/indexable_collection/enqueue.test.ts +++ b/tests/indexable_collection/enqueue.test.ts @@ -1,6 +1,6 @@ import { collection, kvdex, KvValue, model, QueueMessage } from "../../mod.ts" import { createHandlerId } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { createResolver, useDb, useKv } from "../utils.ts" diff --git a/tests/indexable_collection/find.test.ts b/tests/indexable_collection/find.test.ts index 3e02db2..3dea598 100644 --- a/tests/indexable_collection/find.test.ts +++ b/tests/indexable_collection/find.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/findByPrimaryIndex.test.ts b/tests/indexable_collection/findByPrimaryIndex.test.ts index 7fa9602..422521e 100644 --- a/tests/indexable_collection/findByPrimaryIndex.test.ts +++ b/tests/indexable_collection/findByPrimaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { TransformUserModel } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/findBySecondaryIndex.test.ts b/tests/indexable_collection/findBySecondaryIndex.test.ts index c044af8..adf96b2 100644 --- a/tests/indexable_collection/findBySecondaryIndex.test.ts +++ b/tests/indexable_collection/findBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2 } from "../mocks.ts" import { TransformUserModel } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/findMany.test.ts b/tests/indexable_collection/findMany.test.ts index 7140b6a..0503a4b 100644 --- a/tests/indexable_collection/findMany.test.ts +++ b/tests/indexable_collection/findMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers, useDb } from "../utils.ts" Deno.test("indexable_collection - findMany", async (t) => { diff --git a/tests/indexable_collection/forEach.test.ts b/tests/indexable_collection/forEach.test.ts index 5f9fb5a..4675791 100644 --- a/tests/indexable_collection/forEach.test.ts +++ b/tests/indexable_collection/forEach.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { generateUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/forEachBySecondaryIndex.test.ts b/tests/indexable_collection/forEachBySecondaryIndex.test.ts index 42860ab..d12f795 100644 --- a/tests/indexable_collection/forEachBySecondaryIndex.test.ts +++ b/tests/indexable_collection/forEachBySecondaryIndex.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/getMany.test.ts b/tests/indexable_collection/getMany.test.ts index 2c0ef9e..200f6fa 100644 --- a/tests/indexable_collection/getMany.test.ts +++ b/tests/indexable_collection/getMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/getOne.test.ts b/tests/indexable_collection/getOne.test.ts index 7df6133..a121998 100644 --- a/tests/indexable_collection/getOne.test.ts +++ b/tests/indexable_collection/getOne.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { sleep, useDb } from "../utils.ts" import { mockUser1, mockUser2 } from "../mocks.ts" diff --git a/tests/indexable_collection/getOneBySecondaryIndex.test.ts b/tests/indexable_collection/getOneBySecondaryIndex.test.ts index f9c8af1..c24cfe9 100644 --- a/tests/indexable_collection/getOneBySecondaryIndex.test.ts +++ b/tests/indexable_collection/getOneBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { sleep, useDb } from "../utils.ts" import { mockUser1, mockUser2 } from "../mocks.ts" diff --git a/tests/indexable_collection/history.test.ts b/tests/indexable_collection/history.test.ts index 0a38137..0409eae 100644 --- a/tests/indexable_collection/history.test.ts +++ b/tests/indexable_collection/history.test.ts @@ -1,5 +1,5 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers, sleep, useKv } from "../utils.ts" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import type { User } from "../models.ts" diff --git a/tests/indexable_collection/listenQueue.test.ts b/tests/indexable_collection/listenQueue.test.ts index b567ab6..9122481 100644 --- a/tests/indexable_collection/listenQueue.test.ts +++ b/tests/indexable_collection/listenQueue.test.ts @@ -4,7 +4,7 @@ import { UNDELIVERED_KEY_PREFIX, } from "../../src/constants.ts" import { createHandlerId, extendKey } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { createResolver, sleep, useKv } from "../utils.ts" diff --git a/tests/indexable_collection/map.test.ts b/tests/indexable_collection/map.test.ts index 6609c20..ccb3cf6 100644 --- a/tests/indexable_collection/map.test.ts +++ b/tests/indexable_collection/map.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/mapBySecondaryIndex.test.ts b/tests/indexable_collection/mapBySecondaryIndex.test.ts index fcd4a17..384b21c 100644 --- a/tests/indexable_collection/mapBySecondaryIndex.test.ts +++ b/tests/indexable_collection/mapBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/properties.test.ts b/tests/indexable_collection/properties.test.ts index 4c4ab53..8432d9d 100644 --- a/tests/indexable_collection/properties.test.ts +++ b/tests/indexable_collection/properties.test.ts @@ -6,7 +6,7 @@ import { SECONDARY_INDEX_KEY_PREFIX, } from "../../src/constants.ts" import { extendKey, keyEq } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { User } from "../models.ts" import { generateUsers, useDb, useKv } from "../utils.ts" diff --git a/tests/indexable_collection/set.test.ts b/tests/indexable_collection/set.test.ts index ae25191..1d1f471 100644 --- a/tests/indexable_collection/set.test.ts +++ b/tests/indexable_collection/set.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/update.test.ts b/tests/indexable_collection/update.test.ts index aad7e9d..5ec62e0 100644 --- a/tests/indexable_collection/update.test.ts +++ b/tests/indexable_collection/update.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/updateByPrimaryIndex.test.ts b/tests/indexable_collection/updateByPrimaryIndex.test.ts index 8408989..e269cfa 100644 --- a/tests/indexable_collection/updateByPrimaryIndex.test.ts +++ b/tests/indexable_collection/updateByPrimaryIndex.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/updateBySecondaryIndex.test.ts b/tests/indexable_collection/updateBySecondaryIndex.test.ts index 7b9fa11..52c0bcf 100644 --- a/tests/indexable_collection/updateBySecondaryIndex.test.ts +++ b/tests/indexable_collection/updateBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUserInvalid } from "../mocks.ts" import { generateUsers, useDb } from "../utils.ts" diff --git a/tests/indexable_collection/updateMany.test.ts b/tests/indexable_collection/updateMany.test.ts index d12c4b2..b93426c 100644 --- a/tests/indexable_collection/updateMany.test.ts +++ b/tests/indexable_collection/updateMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUserInvalid } from "../mocks.ts" import { generateUsers, useDb } from "../utils.ts" diff --git a/tests/indexable_collection/updateOne.test.ts b/tests/indexable_collection/updateOne.test.ts index 0708999..ee6092f 100644 --- a/tests/indexable_collection/updateOne.test.ts +++ b/tests/indexable_collection/updateOne.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser3 } from "../mocks.ts" import { mockUser2 } from "../mocks.ts" import { mockUser1, mockUserInvalid } from "../mocks.ts" diff --git a/tests/indexable_collection/updateOneBySecondaryIndex.test.ts b/tests/indexable_collection/updateOneBySecondaryIndex.test.ts index 21a7a23..31b7549 100644 --- a/tests/indexable_collection/updateOneBySecondaryIndex.test.ts +++ b/tests/indexable_collection/updateOneBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser3 } from "../mocks.ts" import { mockUser2 } from "../mocks.ts" import { mockUser1, mockUserInvalid } from "../mocks.ts" diff --git a/tests/indexable_collection/upsert.test.ts b/tests/indexable_collection/upsert.test.ts index dd4e0fa..efc4d9c 100644 --- a/tests/indexable_collection/upsert.test.ts +++ b/tests/indexable_collection/upsert.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/upsertByPrimaryIndex.test.ts b/tests/indexable_collection/upsertByPrimaryIndex.test.ts index 914bac5..94b2090 100644 --- a/tests/indexable_collection/upsertByPrimaryIndex.test.ts +++ b/tests/indexable_collection/upsertByPrimaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/indexable_collection/watch.test.ts b/tests/indexable_collection/watch.test.ts index 1b6c72b..7f38926 100644 --- a/tests/indexable_collection/watch.test.ts +++ b/tests/indexable_collection/watch.test.ts @@ -1,72 +1,71 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { sleep, useDb } from "../utils.ts" -Deno.test({ - name: "indexable_collection - watch", - sanitizeResources: false, - sanitizeOps: false, - fn: async (t) => { - await t.step("Should receive all document updates", async () => { - await useDb(async (db) => { - const id = "id" - let count = 0 - let username = "" - let lastDoc: any +Deno.test("indexable_collection - watch", async (t) => { + await t.step("Should receive all document updates", async () => { + await useDb(async (db) => { + const id = "id" + let count = 0 + let username = "" + let lastDoc: any - db.i_users.watch(id, (doc) => { - count++ - lastDoc = doc - if (doc?.value.username) { - username = doc.value.username - } - }) + const watcher = db.i_users.watch(id, (doc) => { + count++ + lastDoc = doc + if (doc?.value.username) { + username = doc.value.username + } + }) - await db.i_users.set(id, mockUser1) - await sleep(500) - await db.i_users.set(id, mockUser2, { overwrite: true }) - await sleep(500) - await db.i_users.update(id, mockUser3) - await sleep(500) - await db.i_users.delete(id) - await sleep(500) + await db.i_users.set(id, mockUser1) + await sleep(500) + await db.i_users.set(id, mockUser2, { overwrite: true }) + await sleep(500) + await db.i_users.update(id, mockUser3) + await sleep(500) + await db.i_users.delete(id) + await sleep(500) - assert(count === 4) - assert(username === mockUser3.username) - assert(lastDoc === null) - }) + assert(count === 4) + assert(username === mockUser3.username) + assert(lastDoc === null) + + return async () => await watcher }) + }) - await t.step("Should not receive unrelated document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id2" - let count = 0 - let username = "" - let lastDoc: any + await t.step("Should not receive unrelated document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id2" + let count = 0 + let username = "" + let lastDoc: any - db.i_users.watch(id1, (doc) => { - count++ - lastDoc = doc - if (doc?.value.username) { - username = doc.value.username - } - }) + const watcher = db.i_users.watch(id1, (doc) => { + count++ + lastDoc = doc + if (doc?.value.username) { + username = doc.value.username + } + }) - await db.i_users.set(id2, mockUser1) - await sleep(500) - await db.i_users.set(id2, mockUser2, { overwrite: true }) - await sleep(500) - await db.i_users.update(id2, mockUser3) - await sleep(500) - await db.i_users.delete(id2) - await sleep(500) + await db.i_users.set(id2, mockUser1) + await sleep(500) + await db.i_users.set(id2, mockUser2, { overwrite: true }) + await sleep(500) + await db.i_users.update(id2, mockUser3) + await sleep(500) + await db.i_users.delete(id2) + await sleep(500) - // Account for initial invocation - assert(count === 1) - assert(username === "") - assert(lastDoc === null) - }) + // Account for initial invocation + assert(count === 1) + assert(username === "") + assert(lastDoc === null) + + return async () => await watcher }) - }, + }) }) diff --git a/tests/indexable_collection/watchMany.test.ts b/tests/indexable_collection/watchMany.test.ts index ed0c1c8..fc80639 100644 --- a/tests/indexable_collection/watchMany.test.ts +++ b/tests/indexable_collection/watchMany.test.ts @@ -1,73 +1,72 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { generateUsers, sleep, useDb } from "../utils.ts" -Deno.test({ - name: "indexable_collection - watchMany", - sanitizeResources: false, - sanitizeOps: false, - fn: async (t) => { - await t.step("Should receive all document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id2" - const id3 = "id3" - let count = 0 - let lastDocs: any[] = [] +Deno.test("indexable_collection - watchMany", async (t) => { + await t.step("Should receive all document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id2" + const id3 = "id3" + let count = 0 + let lastDocs: any[] = [] - await db.i_users.set(id3, generateUsers(1)[0]) + await db.i_users.set(id3, generateUsers(1)[0]) - await sleep(500) + await sleep(500) - db.i_users.watchMany([id1, id2, id3], (docs) => { - count++ - lastDocs = docs - }) + const watcher = db.i_users.watchMany([id1, id2, id3], (docs) => { + count++ + lastDocs = docs + }) - await db.i_users.set(id1, mockUser1) - await sleep(500) - await db.i_users.delete(id1) - await sleep(500) - await db.i_users.set(id2, mockUser2, { overwrite: true }) - await sleep(500) - await db.i_users.update(id3, mockUser3) - await sleep(500) + await db.i_users.set(id1, mockUser1) + await sleep(500) + await db.i_users.delete(id1) + await sleep(500) + await db.i_users.set(id2, mockUser2, { overwrite: true }) + await sleep(500) + await db.i_users.update(id3, mockUser3) + await sleep(500) - assert(count === 4) - assert(lastDocs[0] === null) - assert(lastDocs[1]?.value.username === mockUser2.username) - assert(lastDocs[2]?.value.username === mockUser3.username) - }) + assert(count === 4) + assert(lastDocs[0] === null) + assert(lastDocs[1]?.value.username === mockUser2.username) + assert(lastDocs[2]?.value.username === mockUser3.username) + + return async () => await watcher }) + }) - await t.step("Should not receive unrelated document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id1" - const id3 = "id1" - const id4 = "id4" - let count = 0 - let lastDocs: any[] = [] + await t.step("Should not receive unrelated document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id1" + const id3 = "id1" + const id4 = "id4" + let count = 0 + let lastDocs: any[] = [] - db.i_users.watchMany([id1, id2, id3], (docs) => { - count++ - lastDocs = docs - }) + const watcher = db.i_users.watchMany([id1, id2, id3], (docs) => { + count++ + lastDocs = docs + }) - await db.i_users.set(id4, mockUser1) - await sleep(500) - await db.i_users.set(id4, mockUser2, { overwrite: true }) - await sleep(500) - await db.i_users.update(id4, mockUser3) - await sleep(500) - await db.i_users.delete(id4) - await sleep(500) + await db.i_users.set(id4, mockUser1) + await sleep(500) + await db.i_users.set(id4, mockUser2, { overwrite: true }) + await sleep(500) + await db.i_users.update(id4, mockUser3) + await sleep(500) + await db.i_users.delete(id4) + await sleep(500) - assert(count === 1) - assert(lastDocs[0] === null) - assert(lastDocs[1] === null) - assert(lastDocs[2] === null) - }) + assert(count === 1) + assert(lastDocs[0] === null) + assert(lastDocs[1] === null) + assert(lastDocs[2] === null) + + return async () => await watcher }) - }, + }) }) diff --git a/tests/models.ts b/tests/models.ts index 3c2aff8..2fe919d 100644 --- a/tests/models.ts +++ b/tests/models.ts @@ -1,5 +1,5 @@ import { model } from "../mod.ts" -import { z } from "./deps.ts" +import { z } from "zod" export type Address = z.infer diff --git a/tests/serialized_collection/add.test.ts b/tests/serialized_collection/add.test.ts index 5108137..1c32023 100644 --- a/tests/serialized_collection/add.test.ts +++ b/tests/serialized_collection/add.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUserInvalid } from "../mocks.ts" import { generateLargeUsers, useDb } from "../utils.ts" diff --git a/tests/serialized_collection/addMany.test.ts b/tests/serialized_collection/addMany.test.ts index 5452547..ddf14ec 100644 --- a/tests/serialized_collection/addMany.test.ts +++ b/tests/serialized_collection/addMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateInvalidUsers, generateLargeUsers, useDb } from "../utils.ts" Deno.test("serialized_collection - addMany", async (t) => { diff --git a/tests/serialized_collection/count.test.ts b/tests/serialized_collection/count.test.ts index 6227522..ee92cd9 100644 --- a/tests/serialized_collection/count.test.ts +++ b/tests/serialized_collection/count.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_collection/delete.test.ts b/tests/serialized_collection/delete.test.ts index 8673a58..d16a615 100644 --- a/tests/serialized_collection/delete.test.ts +++ b/tests/serialized_collection/delete.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { generateLargeUsers, useDb } from "../utils.ts" diff --git a/tests/serialized_collection/deleteMany.test.ts b/tests/serialized_collection/deleteMany.test.ts index 8707fe9..b289c00 100644 --- a/tests/serialized_collection/deleteMany.test.ts +++ b/tests/serialized_collection/deleteMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, useDb } from "../utils.ts" Deno.test("serialized_collection - deleteMany", async (t) => { diff --git a/tests/serialized_collection/enqueue.test.ts b/tests/serialized_collection/enqueue.test.ts index 1b5544d..9956996 100644 --- a/tests/serialized_collection/enqueue.test.ts +++ b/tests/serialized_collection/enqueue.test.ts @@ -1,6 +1,6 @@ import { collection, kvdex, KvValue, model, QueueMessage } from "../../mod.ts" import { createHandlerId } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { createResolver, useDb, useKv } from "../utils.ts" diff --git a/tests/serialized_collection/find.test.ts b/tests/serialized_collection/find.test.ts index 3ebe89a..654b1d1 100644 --- a/tests/serialized_collection/find.test.ts +++ b/tests/serialized_collection/find.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_collection/findMany.test.ts b/tests/serialized_collection/findMany.test.ts index df9358f..7ed2e03 100644 --- a/tests/serialized_collection/findMany.test.ts +++ b/tests/serialized_collection/findMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, useDb } from "../utils.ts" Deno.test("serialized_collection - findMany", async (t) => { diff --git a/tests/serialized_collection/forEach.test.ts b/tests/serialized_collection/forEach.test.ts index 1d03edc..c22849f 100644 --- a/tests/serialized_collection/forEach.test.ts +++ b/tests/serialized_collection/forEach.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { generateLargeUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_collection/getMany.test.ts b/tests/serialized_collection/getMany.test.ts index 451ac0a..3e452fe 100644 --- a/tests/serialized_collection/getMany.test.ts +++ b/tests/serialized_collection/getMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_collection/getOne.test.ts b/tests/serialized_collection/getOne.test.ts index ed09081..c4b3622 100644 --- a/tests/serialized_collection/getOne.test.ts +++ b/tests/serialized_collection/getOne.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { sleep, useDb } from "../utils.ts" import { mockUser1, mockUser2 } from "../mocks.ts" diff --git a/tests/serialized_collection/history.test.ts b/tests/serialized_collection/history.test.ts index 7600529..a7eda74 100644 --- a/tests/serialized_collection/history.test.ts +++ b/tests/serialized_collection/history.test.ts @@ -1,5 +1,5 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { sleep, useKv } from "../utils.ts" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import type { User } from "../models.ts" diff --git a/tests/serialized_collection/listenQueue.test.ts b/tests/serialized_collection/listenQueue.test.ts index 250aadd..2fe5ba4 100644 --- a/tests/serialized_collection/listenQueue.test.ts +++ b/tests/serialized_collection/listenQueue.test.ts @@ -4,7 +4,7 @@ import { UNDELIVERED_KEY_PREFIX, } from "../../src/constants.ts" import { createHandlerId, extendKey } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { createResolver, sleep, useKv } from "../utils.ts" diff --git a/tests/serialized_collection/map.test.ts b/tests/serialized_collection/map.test.ts index a490cee..f092e95 100644 --- a/tests/serialized_collection/map.test.ts +++ b/tests/serialized_collection/map.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_collection/properties.test.ts b/tests/serialized_collection/properties.test.ts index c22ef64..c2434c3 100644 --- a/tests/serialized_collection/properties.test.ts +++ b/tests/serialized_collection/properties.test.ts @@ -5,7 +5,7 @@ import { SEGMENT_KEY_PREFIX, } from "../../src/constants.ts" import { extendKey, keyEq } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1 } from "../mocks.ts" import { User } from "../models.ts" import { generateLargeUsers, useDb, useKv } from "../utils.ts" diff --git a/tests/serialized_collection/set.test.ts b/tests/serialized_collection/set.test.ts index 14904b7..7d4c611 100644 --- a/tests/serialized_collection/set.test.ts +++ b/tests/serialized_collection/set.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_collection/types.test.ts b/tests/serialized_collection/types.test.ts index ce2fb2c..11a1fd1 100644 --- a/tests/serialized_collection/types.test.ts +++ b/tests/serialized_collection/types.test.ts @@ -1,5 +1,5 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { useKv } from "../utils.ts" Deno.test("serialized_collection - types", async (t) => { diff --git a/tests/serialized_collection/update.test.ts b/tests/serialized_collection/update.test.ts index d41c3af..0c77290 100644 --- a/tests/serialized_collection/update.test.ts +++ b/tests/serialized_collection/update.test.ts @@ -1,5 +1,6 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert, assertEquals } from "../deps.ts" +import { assertEquals } from "assert_equals" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { useDb, useKv } from "../utils.ts" diff --git a/tests/serialized_collection/updateMany.test.ts b/tests/serialized_collection/updateMany.test.ts index e2d5a55..625368d 100644 --- a/tests/serialized_collection/updateMany.test.ts +++ b/tests/serialized_collection/updateMany.test.ts @@ -1,5 +1,6 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert, assertEquals } from "../deps.ts" +import { assertEquals } from "assert_equals" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUserInvalid } from "../mocks.ts" import { generateNumbers, generateUsers, useDb, useKv } from "../utils.ts" diff --git a/tests/serialized_collection/updateOne.test.ts b/tests/serialized_collection/updateOne.test.ts index 4491113..7ff094c 100644 --- a/tests/serialized_collection/updateOne.test.ts +++ b/tests/serialized_collection/updateOne.test.ts @@ -1,5 +1,7 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert, assertEquals, assertNotEquals } from "../deps.ts" +import { assertEquals } from "assert_equals" +import { assertNotEquals } from "assert_not_equals" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser3 } from "../mocks.ts" import { mockUser2 } from "../mocks.ts" import { mockUser1, mockUserInvalid } from "../mocks.ts" diff --git a/tests/serialized_collection/upsert.test.ts b/tests/serialized_collection/upsert.test.ts index 0792b6a..7cd3d0c 100644 --- a/tests/serialized_collection/upsert.test.ts +++ b/tests/serialized_collection/upsert.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_collection/watch.test.ts b/tests/serialized_collection/watch.test.ts index b652188..d260e19 100644 --- a/tests/serialized_collection/watch.test.ts +++ b/tests/serialized_collection/watch.test.ts @@ -1,72 +1,71 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { sleep, useDb } from "../utils.ts" -Deno.test({ - name: "serialized_collection - watch", - sanitizeResources: false, - sanitizeOps: false, - fn: async (t) => { - await t.step("Should receive all document updates", async () => { - await useDb(async (db) => { - const id = "id" - let count = 0 - let username = "" - let lastDoc: any +Deno.test("serialized_collection - watch", async (t) => { + await t.step("Should receive all document updates", async () => { + await useDb(async (db) => { + const id = "id" + let count = 0 + let username = "" + let lastDoc: any - db.s_users.watch(id, (doc) => { - count++ - lastDoc = doc - if (doc?.value.username) { - username = doc.value.username - } - }) + const watcher = db.s_users.watch(id, (doc) => { + count++ + lastDoc = doc + if (doc?.value.username) { + username = doc.value.username + } + }) - await db.s_users.set(id, mockUser1) - await sleep(500) - await db.s_users.set(id, mockUser2, { overwrite: true }) - await sleep(500) - await db.s_users.update(id, mockUser3) - await sleep(500) - await db.s_users.delete(id) - await sleep(500) + await db.s_users.set(id, mockUser1) + await sleep(500) + await db.s_users.set(id, mockUser2, { overwrite: true }) + await sleep(500) + await db.s_users.update(id, mockUser3) + await sleep(500) + await db.s_users.delete(id) + await sleep(500) - assert(count === 4) - assert(username === mockUser3.username) - assert(lastDoc === null) - }) + assert(count === 4) + assert(username === mockUser3.username) + assert(lastDoc === null) + + return async () => await watcher }) + }) - await t.step("Should not receive unrelated document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id2" - let count = 0 - let username = "" - let lastDoc: any + await t.step("Should not receive unrelated document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id2" + let count = 0 + let username = "" + let lastDoc: any - db.s_users.watch(id1, (doc) => { - count++ - lastDoc = doc - if (doc?.value.username) { - username = doc.value.username - } - }) + const watcher = db.s_users.watch(id1, (doc) => { + count++ + lastDoc = doc + if (doc?.value.username) { + username = doc.value.username + } + }) - await db.s_users.set(id2, mockUser1) - await sleep(500) - await db.s_users.set(id2, mockUser2, { overwrite: true }) - await sleep(500) - await db.s_users.update(id2, mockUser3) - await sleep(500) - await db.s_users.delete(id2) - await sleep(500) + await db.s_users.set(id2, mockUser1) + await sleep(500) + await db.s_users.set(id2, mockUser2, { overwrite: true }) + await sleep(500) + await db.s_users.update(id2, mockUser3) + await sleep(500) + await db.s_users.delete(id2) + await sleep(500) - // Account for initial invocation - assert(count === 1) - assert(username === "") - assert(lastDoc === null) - }) + // Account for initial invocation + assert(count === 1) + assert(username === "") + assert(lastDoc === null) + + return async () => await watcher }) - }, + }) }) diff --git a/tests/serialized_collection/watchMany.test.ts b/tests/serialized_collection/watchMany.test.ts index f5360f6..69f6c94 100644 --- a/tests/serialized_collection/watchMany.test.ts +++ b/tests/serialized_collection/watchMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { sleep, useDb } from "../utils.ts" @@ -17,7 +17,7 @@ Deno.test({ await db.s_users.set(id3, mockUser1) - db.s_users.watchMany([id1, id2, id3], (docs) => { + const watcher = db.s_users.watchMany([id1, id2, id3], (docs) => { count++ lastDocs = docs }) @@ -35,6 +35,8 @@ Deno.test({ assert(lastDocs[0] === null) assert(lastDocs[1]?.value.username === mockUser2.username) assert(lastDocs[2]?.value.username === mockUser3.username) + + return async () => await watcher }) }) @@ -47,7 +49,7 @@ Deno.test({ let count = 0 let lastDocs: any[] = [] - db.s_users.watchMany([id1, id2, id3], (docs) => { + const watcher = db.s_users.watchMany([id1, id2, id3], (docs) => { count++ lastDocs = docs }) @@ -65,6 +67,8 @@ Deno.test({ assert(lastDocs[0] === null) assert(lastDocs[1] === null) assert(lastDocs[2] === null) + + return async () => await watcher }) }) }, diff --git a/tests/serialized_indexable_collection/add.test.ts b/tests/serialized_indexable_collection/add.test.ts index d3db403..ae9cacf 100644 --- a/tests/serialized_indexable_collection/add.test.ts +++ b/tests/serialized_indexable_collection/add.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUserInvalid } from "../mocks.ts" import { generateLargeUsers, useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/addMany.test.ts b/tests/serialized_indexable_collection/addMany.test.ts index 9595377..b911001 100644 --- a/tests/serialized_indexable_collection/addMany.test.ts +++ b/tests/serialized_indexable_collection/addMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateInvalidUsers, generateLargeUsers, useDb } from "../utils.ts" const [user] = generateLargeUsers(1) diff --git a/tests/serialized_indexable_collection/count.test.ts b/tests/serialized_indexable_collection/count.test.ts index b82c83a..fe5165c 100644 --- a/tests/serialized_indexable_collection/count.test.ts +++ b/tests/serialized_indexable_collection/count.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/countBySecondaryIndex.test.ts b/tests/serialized_indexable_collection/countBySecondaryIndex.test.ts index 6125195..4eeb252 100644 --- a/tests/serialized_indexable_collection/countBySecondaryIndex.test.ts +++ b/tests/serialized_indexable_collection/countBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/delete.test.ts b/tests/serialized_indexable_collection/delete.test.ts index b29bf27..59fa2bc 100644 --- a/tests/serialized_indexable_collection/delete.test.ts +++ b/tests/serialized_indexable_collection/delete.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, useDb } from "../utils.ts" const [user] = generateLargeUsers(1) diff --git a/tests/serialized_indexable_collection/deleteByPrimaryIndex.test.ts b/tests/serialized_indexable_collection/deleteByPrimaryIndex.test.ts index ae83c5e..a9be4f8 100644 --- a/tests/serialized_indexable_collection/deleteByPrimaryIndex.test.ts +++ b/tests/serialized_indexable_collection/deleteByPrimaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, useDb } from "../utils.ts" const [user] = generateLargeUsers(1) diff --git a/tests/serialized_indexable_collection/deleteBySecondaryIndex.test.ts b/tests/serialized_indexable_collection/deleteBySecondaryIndex.test.ts index 74ace70..f3007a3 100644 --- a/tests/serialized_indexable_collection/deleteBySecondaryIndex.test.ts +++ b/tests/serialized_indexable_collection/deleteBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, useDb } from "../utils.ts" const [user1, user2] = generateLargeUsers(2) diff --git a/tests/serialized_indexable_collection/deleteMany.test.ts b/tests/serialized_indexable_collection/deleteMany.test.ts index d57bf71..30b56a8 100644 --- a/tests/serialized_indexable_collection/deleteMany.test.ts +++ b/tests/serialized_indexable_collection/deleteMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, useDb } from "../utils.ts" Deno.test("serialized_indexable_collection - deleteMany", async (t) => { diff --git a/tests/serialized_indexable_collection/enqueue.test.ts b/tests/serialized_indexable_collection/enqueue.test.ts index fa7100d..8cf94b9 100644 --- a/tests/serialized_indexable_collection/enqueue.test.ts +++ b/tests/serialized_indexable_collection/enqueue.test.ts @@ -1,6 +1,6 @@ import { collection, kvdex, KvValue, model, QueueMessage } from "../../mod.ts" import { createHandlerId } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { createResolver, useDb, useKv } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/find.test.ts b/tests/serialized_indexable_collection/find.test.ts index 6d67630..f12f93c 100644 --- a/tests/serialized_indexable_collection/find.test.ts +++ b/tests/serialized_indexable_collection/find.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, useDb } from "../utils.ts" const [user] = generateLargeUsers(1) diff --git a/tests/serialized_indexable_collection/findByPrimaryIndex.test.ts b/tests/serialized_indexable_collection/findByPrimaryIndex.test.ts index 263cdae..12bfb03 100644 --- a/tests/serialized_indexable_collection/findByPrimaryIndex.test.ts +++ b/tests/serialized_indexable_collection/findByPrimaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { TransformUserModel } from "../models.ts" import { generateLargeUsers, useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/findBySecondaryIndex.test.ts b/tests/serialized_indexable_collection/findBySecondaryIndex.test.ts index ba64c97..f44535d 100644 --- a/tests/serialized_indexable_collection/findBySecondaryIndex.test.ts +++ b/tests/serialized_indexable_collection/findBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2 } from "../mocks.ts" import { TransformUserModel } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/findMany.test.ts b/tests/serialized_indexable_collection/findMany.test.ts index 07aaf89..7311e49 100644 --- a/tests/serialized_indexable_collection/findMany.test.ts +++ b/tests/serialized_indexable_collection/findMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, useDb } from "../utils.ts" Deno.test("serialized_indexable_collection - findMany", async (t) => { diff --git a/tests/serialized_indexable_collection/forEach.test.ts b/tests/serialized_indexable_collection/forEach.test.ts index 643bd08..c0b95f9 100644 --- a/tests/serialized_indexable_collection/forEach.test.ts +++ b/tests/serialized_indexable_collection/forEach.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { generateLargeUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/forEachBySecondaryIndex.test.ts b/tests/serialized_indexable_collection/forEachBySecondaryIndex.test.ts index 6053ec5..f616327 100644 --- a/tests/serialized_indexable_collection/forEachBySecondaryIndex.test.ts +++ b/tests/serialized_indexable_collection/forEachBySecondaryIndex.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/getMany.test.ts b/tests/serialized_indexable_collection/getMany.test.ts index fad0e09..e6d20bb 100644 --- a/tests/serialized_indexable_collection/getMany.test.ts +++ b/tests/serialized_indexable_collection/getMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/getOne.test.ts b/tests/serialized_indexable_collection/getOne.test.ts index 60d6026..ad5f184 100644 --- a/tests/serialized_indexable_collection/getOne.test.ts +++ b/tests/serialized_indexable_collection/getOne.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { sleep, useDb } from "../utils.ts" import { mockUser1, mockUser2 } from "../mocks.ts" diff --git a/tests/serialized_indexable_collection/getOneBySecondaryIndex.test.ts b/tests/serialized_indexable_collection/getOneBySecondaryIndex.test.ts index a861cd5..e6c662e 100644 --- a/tests/serialized_indexable_collection/getOneBySecondaryIndex.test.ts +++ b/tests/serialized_indexable_collection/getOneBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { sleep, useDb } from "../utils.ts" import { mockUser1, mockUser2 } from "../mocks.ts" diff --git a/tests/serialized_indexable_collection/history.test.ts b/tests/serialized_indexable_collection/history.test.ts index 55f6a61..1bb95ac 100644 --- a/tests/serialized_indexable_collection/history.test.ts +++ b/tests/serialized_indexable_collection/history.test.ts @@ -1,5 +1,5 @@ import { collection, kvdex, model } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers, sleep, useKv } from "../utils.ts" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import type { User } from "../models.ts" diff --git a/tests/serialized_indexable_collection/listenQueue.test.ts b/tests/serialized_indexable_collection/listenQueue.test.ts index 06f6fe9..6de1e4f 100644 --- a/tests/serialized_indexable_collection/listenQueue.test.ts +++ b/tests/serialized_indexable_collection/listenQueue.test.ts @@ -4,7 +4,7 @@ import { UNDELIVERED_KEY_PREFIX, } from "../../src/constants.ts" import { createHandlerId, extendKey } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { createResolver, sleep, useKv } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/map.test.ts b/tests/serialized_indexable_collection/map.test.ts index 8df2d3a..4b3c0c8 100644 --- a/tests/serialized_indexable_collection/map.test.ts +++ b/tests/serialized_indexable_collection/map.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { generateLargeUsers } from "../utils.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/mapBySecondaryIndex.test.ts b/tests/serialized_indexable_collection/mapBySecondaryIndex.test.ts index f79ca93..c7077a2 100644 --- a/tests/serialized_indexable_collection/mapBySecondaryIndex.test.ts +++ b/tests/serialized_indexable_collection/mapBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/properties.test.ts b/tests/serialized_indexable_collection/properties.test.ts index f830f5b..4d51074 100644 --- a/tests/serialized_indexable_collection/properties.test.ts +++ b/tests/serialized_indexable_collection/properties.test.ts @@ -6,7 +6,7 @@ import { SECONDARY_INDEX_KEY_PREFIX, } from "../../src/constants.ts" import { extendKey, keyEq } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { User } from "../models.ts" import { generateLargeUsers, useDb, useKv } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/set.test.ts b/tests/serialized_indexable_collection/set.test.ts index d57ae50..beb2900 100644 --- a/tests/serialized_indexable_collection/set.test.ts +++ b/tests/serialized_indexable_collection/set.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUserInvalid } from "../mocks.ts" import { generateLargeUsers, useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/update.test.ts b/tests/serialized_indexable_collection/update.test.ts index 8e04552..58e0dd6 100644 --- a/tests/serialized_indexable_collection/update.test.ts +++ b/tests/serialized_indexable_collection/update.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/updateByPrimaryIndex.test.ts b/tests/serialized_indexable_collection/updateByPrimaryIndex.test.ts index 2b89e85..001d18f 100644 --- a/tests/serialized_indexable_collection/updateByPrimaryIndex.test.ts +++ b/tests/serialized_indexable_collection/updateByPrimaryIndex.test.ts @@ -1,5 +1,5 @@ import { Document } from "../../mod.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUserInvalid } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/updateBySecondaryIndex.test.ts b/tests/serialized_indexable_collection/updateBySecondaryIndex.test.ts index ce12eae..dea1b35 100644 --- a/tests/serialized_indexable_collection/updateBySecondaryIndex.test.ts +++ b/tests/serialized_indexable_collection/updateBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUserInvalid } from "../mocks.ts" import { generateUsers, useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/updateMany.test.ts b/tests/serialized_indexable_collection/updateMany.test.ts index e50a906..fd66bb2 100644 --- a/tests/serialized_indexable_collection/updateMany.test.ts +++ b/tests/serialized_indexable_collection/updateMany.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUserInvalid } from "../mocks.ts" import { generateUsers, useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/updateOne.test.ts b/tests/serialized_indexable_collection/updateOne.test.ts index 97ec0ee..2757e40 100644 --- a/tests/serialized_indexable_collection/updateOne.test.ts +++ b/tests/serialized_indexable_collection/updateOne.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser3 } from "../mocks.ts" import { mockUser2 } from "../mocks.ts" import { mockUser1, mockUserInvalid } from "../mocks.ts" diff --git a/tests/serialized_indexable_collection/updateOneBySecondaryIndex.test.ts b/tests/serialized_indexable_collection/updateOneBySecondaryIndex.test.ts index a0add5e..3f76f96 100644 --- a/tests/serialized_indexable_collection/updateOneBySecondaryIndex.test.ts +++ b/tests/serialized_indexable_collection/updateOneBySecondaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser3 } from "../mocks.ts" import { mockUser2 } from "../mocks.ts" import { mockUser1, mockUserInvalid } from "../mocks.ts" diff --git a/tests/serialized_indexable_collection/upsert.test.ts b/tests/serialized_indexable_collection/upsert.test.ts index 1446b98..5320b32 100644 --- a/tests/serialized_indexable_collection/upsert.test.ts +++ b/tests/serialized_indexable_collection/upsert.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/upsertByPrimaryIndex.test.ts b/tests/serialized_indexable_collection/upsertByPrimaryIndex.test.ts index 303d8d0..726006a 100644 --- a/tests/serialized_indexable_collection/upsertByPrimaryIndex.test.ts +++ b/tests/serialized_indexable_collection/upsertByPrimaryIndex.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { User } from "../models.ts" import { useDb } from "../utils.ts" diff --git a/tests/serialized_indexable_collection/watch.test.ts b/tests/serialized_indexable_collection/watch.test.ts index 15009c6..175ba93 100644 --- a/tests/serialized_indexable_collection/watch.test.ts +++ b/tests/serialized_indexable_collection/watch.test.ts @@ -1,72 +1,71 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { sleep, useDb } from "../utils.ts" -Deno.test({ - name: "serialized_indexable_collection - watch", - sanitizeResources: false, - sanitizeOps: false, - fn: async (t) => { - await t.step("Should receive all document updates", async () => { - await useDb(async (db) => { - const id = "id" - let count = 0 - let username = "" - let lastDoc: any +Deno.test("serialized_indexable_collection - watch", async (t) => { + await t.step("Should receive all document updates", async () => { + await useDb(async (db) => { + const id = "id" + let count = 0 + let username = "" + let lastDoc: any - db.is_users.watch(id, (doc) => { - count++ - lastDoc = doc - if (doc?.value.username) { - username = doc.value.username - } - }) + const watcher = db.is_users.watch(id, (doc) => { + count++ + lastDoc = doc + if (doc?.value.username) { + username = doc.value.username + } + }) - await db.is_users.set(id, mockUser1) - await sleep(500) - await db.is_users.set(id, mockUser2, { overwrite: true }) - await sleep(500) - await db.is_users.update(id, mockUser3) - await sleep(500) - await db.is_users.delete(id) - await sleep(500) + await db.is_users.set(id, mockUser1) + await sleep(500) + await db.is_users.set(id, mockUser2, { overwrite: true }) + await sleep(500) + await db.is_users.update(id, mockUser3) + await sleep(500) + await db.is_users.delete(id) + await sleep(500) - assert(count === 4) - assert(username === mockUser3.username) - assert(lastDoc === null) - }) + assert(count === 4) + assert(username === mockUser3.username) + assert(lastDoc === null) + + return async () => await watcher }) + }) - await t.step("Should not receive unrelated document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id2" - let count = 0 - let username = "" - let lastDoc: any + await t.step("Should not receive unrelated document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id2" + let count = 0 + let username = "" + let lastDoc: any - db.is_users.watch(id1, (doc) => { - count++ - lastDoc = doc - if (doc?.value.username) { - username = doc.value.username - } - }) + const watcher = db.is_users.watch(id1, (doc) => { + count++ + lastDoc = doc + if (doc?.value.username) { + username = doc.value.username + } + }) - await db.is_users.set(id2, mockUser1) - await sleep(500) - await db.is_users.set(id2, mockUser2, { overwrite: true }) - await sleep(500) - await db.is_users.update(id2, mockUser3) - await sleep(500) - await db.is_users.delete(id2) - await sleep(500) + await db.is_users.set(id2, mockUser1) + await sleep(500) + await db.is_users.set(id2, mockUser2, { overwrite: true }) + await sleep(500) + await db.is_users.update(id2, mockUser3) + await sleep(500) + await db.is_users.delete(id2) + await sleep(500) - // Account for initial invocation - assert(count === 1) - assert(username === "") - assert(lastDoc === null) - }) + // Account for initial invocation + assert(count === 1) + assert(username === "") + assert(lastDoc === null) + + return async () => await watcher }) - }, + }) }) diff --git a/tests/serialized_indexable_collection/watchMany.test.ts b/tests/serialized_indexable_collection/watchMany.test.ts index ba7395c..d21ec33 100644 --- a/tests/serialized_indexable_collection/watchMany.test.ts +++ b/tests/serialized_indexable_collection/watchMany.test.ts @@ -1,73 +1,72 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { mockUser1, mockUser2, mockUser3 } from "../mocks.ts" import { generateUsers, sleep, useDb } from "../utils.ts" -Deno.test({ - name: "serialized_indexable_collection - watchMany", - sanitizeResources: false, - sanitizeOps: false, - fn: async (t) => { - await t.step("Should receive all document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id2" - const id3 = "id3" - let count = 0 - let lastDocs: any[] = [] +Deno.test("serialized_indexable_collection - watchMany", async (t) => { + await t.step("Should receive all document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id2" + const id3 = "id3" + let count = 0 + let lastDocs: any[] = [] - await db.is_users.set(id3, generateUsers(1)[0]) + await db.is_users.set(id3, generateUsers(1)[0]) - await sleep(500) + await sleep(500) - db.is_users.watchMany([id1, id2, id3], (docs) => { - count++ - lastDocs = docs - }) + const watcher = db.is_users.watchMany([id1, id2, id3], (docs) => { + count++ + lastDocs = docs + }) - await db.is_users.set(id1, mockUser1) - await sleep(500) - await db.is_users.delete(id1) - await sleep(500) - await db.is_users.set(id2, mockUser2, { overwrite: true }) - await sleep(500) - await db.is_users.update(id3, mockUser3) - await sleep(500) + await db.is_users.set(id1, mockUser1) + await sleep(500) + await db.is_users.delete(id1) + await sleep(500) + await db.is_users.set(id2, mockUser2, { overwrite: true }) + await sleep(500) + await db.is_users.update(id3, mockUser3) + await sleep(500) - assert(count === 4) - assert(lastDocs[0] === null) - assert(lastDocs[1]?.value.username === mockUser2.username) - assert(lastDocs[2]?.value.username === mockUser3.username) - }) + assert(count === 4) + assert(lastDocs[0] === null) + assert(lastDocs[1]?.value.username === mockUser2.username) + assert(lastDocs[2]?.value.username === mockUser3.username) + + return async () => await watcher }) + }) - await t.step("Should not receive unrelated document updates", async () => { - await useDb(async (db) => { - const id1 = "id1" - const id2 = "id1" - const id3 = "id1" - const id4 = "id4" - let count = 0 - let lastDocs: any[] = [] + await t.step("Should not receive unrelated document updates", async () => { + await useDb(async (db) => { + const id1 = "id1" + const id2 = "id1" + const id3 = "id1" + const id4 = "id4" + let count = 0 + let lastDocs: any[] = [] - db.is_users.watchMany([id1, id2, id3], (docs) => { - count++ - lastDocs = docs - }) + const watcher = db.is_users.watchMany([id1, id2, id3], (docs) => { + count++ + lastDocs = docs + }) - await db.is_users.set(id4, mockUser1) - await sleep(500) - await db.is_users.set(id4, mockUser2, { overwrite: true }) - await sleep(500) - await db.is_users.update(id4, mockUser3) - await sleep(500) - await db.is_users.delete(id4) - await sleep(500) + await db.is_users.set(id4, mockUser1) + await sleep(500) + await db.is_users.set(id4, mockUser2, { overwrite: true }) + await sleep(500) + await db.is_users.update(id4, mockUser3) + await sleep(500) + await db.is_users.delete(id4) + await sleep(500) - assert(count === 1) - assert(lastDocs[0] === null) - assert(lastDocs[1] === null) - assert(lastDocs[2] === null) - }) + assert(count === 1) + assert(lastDocs[0] === null) + assert(lastDocs[1] === null) + assert(lastDocs[2] === null) + + return async () => await watcher }) - }, + }) }) diff --git a/tests/utils/coreSerialize.test.ts b/tests/utils/coreSerialize.test.ts index 726858d..c37314a 100644 --- a/tests/utils/coreSerialize.test.ts +++ b/tests/utils/coreSerialize.test.ts @@ -1,5 +1,5 @@ import { denoCoreSerialize as serialize } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { val1, val10, diff --git a/tests/utils/denoCoreDeserialize.test.ts b/tests/utils/denoCoreDeserialize.test.ts index f3bf51a..ec6b8f6 100644 --- a/tests/utils/denoCoreDeserialize.test.ts +++ b/tests/utils/denoCoreDeserialize.test.ts @@ -2,7 +2,7 @@ import { denoCoreDeserialize as deserialize, denoCoreSerialize as serialize, } from "../../src/utils.ts" -import { assertEquals } from "../deps.ts" +import { assertEquals } from "assert_equals" import { val1, val10, diff --git a/tests/utils/isKvObject.test.ts b/tests/utils/isKvObject.test.ts index dad36cc..472c527 100644 --- a/tests/utils/isKvObject.test.ts +++ b/tests/utils/isKvObject.test.ts @@ -1,4 +1,4 @@ -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { val1, val10, diff --git a/tests/utils/jsonDeserialize.test.ts b/tests/utils/jsonDeserialize.test.ts index 59ad425..f20cd5f 100644 --- a/tests/utils/jsonDeserialize.test.ts +++ b/tests/utils/jsonDeserialize.test.ts @@ -1,5 +1,5 @@ import { jsonDeserialize, jsonSerialize } from "../../src/utils.ts" -import { assertEquals } from "../deps.ts" +import { assertEquals } from "assert_equals" import { val1, val10, diff --git a/tests/utils/jsonSerialize.test.ts b/tests/utils/jsonSerialize.test.ts index 16a9707..9d0c075 100644 --- a/tests/utils/jsonSerialize.test.ts +++ b/tests/utils/jsonSerialize.test.ts @@ -1,5 +1,5 @@ import { jsonSerialize } from "../../src/utils.ts" -import { assert } from "../deps.ts" +import { assert } from "jsr:@std/assert@0.215/assert" import { val1, val10, From e512dfe3705067e8e42f1d44d2116f826f679a00 Mon Sep 17 00:00:00 2001 From: oliver-oloughlin Date: Wed, 14 Feb 2024 02:14:00 +0100 Subject: [PATCH 2/2] fix: updated std/assert/assert import --- deno.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.json b/deno.json index 2e12a42..211bf08 100644 --- a/deno.json +++ b/deno.json @@ -6,7 +6,7 @@ "./ext/zod": "./ext/zod.ts" }, "imports": { - "assert": "jsr:@std/assert@0.215", + "assert": "jsr:@std/assert@0.215/assert", "assert_equals": "jsr:@std/assert@0.215/assert_equals", "assert_not_equals": "jsr:@std/assert@0.215/assert_not_equals", "assert_throws": "jsr:@std/assert@0.215/assert_throws",