feature: initial commit
This commit is contained in:
commit
ce024ba87a
17 changed files with 1141 additions and 0 deletions
39
tests/02_store_and_retrieve_an_item.test.ts
Normal file
39
tests/02_store_and_retrieve_an_item.test.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
import * as asserts from '@std/assert';
|
||||
import * as fsdb from '../fsdb.ts';
|
||||
import { get_data_dir } from './helpers.ts';
|
||||
|
||||
Deno.test({
|
||||
name: 'store and retrieve an item',
|
||||
permissions: {
|
||||
env: true,
|
||||
read: ['./'],
|
||||
write: ['./data']
|
||||
},
|
||||
fn: async () => {
|
||||
type ITEM = {
|
||||
id: string;
|
||||
value: string;
|
||||
};
|
||||
|
||||
const items: fsdb.FSDB_COLLECTION<ITEM> = new fsdb.FSDB_COLLECTION<ITEM>({
|
||||
name: 'test-02-items',
|
||||
root: get_data_dir() + '/test-02-items'
|
||||
});
|
||||
|
||||
asserts.assert(items);
|
||||
|
||||
const item = {
|
||||
id: 'blah-fish-test-with-cozy-home-down-here-yall-work',
|
||||
value: 'the blah fish test, of course'
|
||||
};
|
||||
|
||||
const stored_item = await items.create(item);
|
||||
|
||||
asserts.assertObjectMatch(stored_item, item);
|
||||
|
||||
const fetched_item = await items.get(item.id);
|
||||
|
||||
asserts.assert(fetched_item);
|
||||
asserts.assertObjectMatch(fetched_item, stored_item);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue