-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from ronhippler/master
fix build and test deps
- Loading branch information
Showing
3 changed files
with
16 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
@@ -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 }; | ||
} | ||
|
||
|