-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathtypes.test.ts
More file actions
29 lines (26 loc) · 976 Bytes
/
Copy pathtypes.test.ts
File metadata and controls
29 lines (26 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { isCouchDBPeer, isStoragePeer, type PeerConf } from "./types.ts";
function assert(condition: unknown, message: string) {
if (!condition) throw new Error(message);
}
Deno.test("peer type guards identify storage and CouchDB peers", () => {
const storage: PeerConf = {
type: "storage",
name: "files",
baseDir: "vault",
};
const couchdb: PeerConf = {
type: "couchdb",
name: "remote",
database: "db",
username: "user",
password: "pass",
url: "http://localhost:5984",
passphrase: "",
obfuscatePassphrase: "",
baseDir: "",
};
assert(isStoragePeer(storage), "storage peer should match storage guard");
assert(!isCouchDBPeer(storage), "storage peer should not match CouchDB guard");
assert(isCouchDBPeer(couchdb), "CouchDB peer should match CouchDB guard");
assert(!isStoragePeer(couchdb), "CouchDB peer should not match storage guard");
});