Skip to content

Commit

Permalink
Merge pull request #10 from ronhippler/master
Browse files Browse the repository at this point in the history
fix build and test deps
  • Loading branch information
manyuanrong authored Apr 4, 2020
2 parents a13e392 + 8edaaaf commit 91e53c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions ts/tests/types-check.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { assertThrows } from "https://deno.land/[email protected]/testing/asserts.ts";
import { assertEquals, assertThrows } from "../../test.deps.ts";
import { ObjectId } from "../types.ts";

Deno.test("ObjectId parse", function() {
assertThrows(() => ObjectId("d3e48b03-7baf-4d98-8df7-5002a8fae5e4"));
ObjectId("5e63a91b00d839ae0084dfe4");
let $oid = "d3e48b03-7baf-4d98-8df7-5002a8fae5e4";
assertThrows(() => ObjectId($oid));
$oid = "5e63a91b00d839ae0084dfe4";
assertEquals(ObjectId($oid), { $oid });
});
6 changes: 3 additions & 3 deletions ts/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { assert } from "https://deno.land/[email protected]/testing/asserts.ts";

export enum CommandType {
ConnectWithUri = "ConnectWithUri",
ConnectWithOptions = "ConnectWithOptions",
Expand All @@ -20,7 +18,9 @@ export interface ObjectId {
}
export function ObjectId($oid: string) {
const isLegal = /[0-9a-fA-F]{24}/.test($oid);
assert(isLegal, `ObjectId("${$oid}") is not legal.`);
if (!isLegal) {
throw new Error(`ObjectId("${$oid}") is not legal.`);
}
return { $oid };
}

Expand Down

0 comments on commit 91e53c7

Please sign in to comment.