Skip to content

Commit

Permalink
lint and build
Browse files Browse the repository at this point in the history
  • Loading branch information
jchris committed Sep 19, 2024
1 parent dfea2c9 commit f9e4ec1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Database<DT extends DocTypes = NonNullable<unknown>> implements Con
name,
meta: opts?.meta,
factoryUnreg: () => {
databases.unreg(key);
// databases.unreg(key);
},
keyBag: defaultKeyBagOpts(sthis, opts?.keyBag),
storeUrls: toStoreURIRuntime(sthis, name, opts?.storeUrls),
Expand Down
67 changes: 47 additions & 20 deletions tests/fireproof/crdt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ describe("Fresh crdt", function () {
await sthis.start();
const dbOpts: DatabaseOpts = {
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, "test-indexer-cold"),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT(sthis, dbOpts);
});
it("should have an empty head", async function () {
Expand Down Expand Up @@ -59,10 +62,13 @@ describe("CRDT with one record", function () {
await sthis.start();
const dbOpts: DatabaseOpts = {
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, `test@${sthis.nextId()}`),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT(sthis, dbOpts);
firstPut = await crdt.bulk([{ id: "hello", value: { hello: "world" } }]);
});
Expand Down Expand Up @@ -115,10 +121,13 @@ describe("CRDT with a multi-write", function () {
await sthis.start();
const dbOpts: DatabaseOpts = {
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, "test-indexer-cold"),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT(sthis, dbOpts);
firstPut = await crdt.bulk([
{ id: "ace", value: { points: 11 } },
Expand Down Expand Up @@ -186,10 +195,13 @@ describe("CRDT with two multi-writes", function () {
await sthis.start();
const dbOpts: DatabaseOpts = {
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, `test-multiple-writes@${sthis.nextId()}`),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT(sthis, dbOpts);
firstPut = await crdt.bulk([
{ id: "ace", value: { points: 11 } },
Expand Down Expand Up @@ -240,10 +252,13 @@ describe("Compact a named CRDT with writes", function () {
await sthis.start();
const dbOpts: DatabaseOpts = {
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, `named-crdt-compaction`),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT(sthis, dbOpts);
for (let i = 0; i < 10; i++) {
const bulk = [
Expand Down Expand Up @@ -301,11 +316,14 @@ describe("CRDT with an index", function () {
beforeEach(async function () {
await sthis.start();
const dbOpts: DatabaseOpts = {
// meta: opts?.meta,
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, "test-indexer-cold"),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeUrls: toStoreURIRuntime(sthis, "test-indexer-cold"),
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT<CRDTTestType>(sthis, dbOpts);
await crdt.bulk([
{ id: "ace", value: { points: 11 } },
Expand Down Expand Up @@ -355,9 +373,12 @@ describe("Loader with a committed transaction", function () {
const dbOpts: DatabaseOpts = {
keyBag: defaultKeyBagOpts(sthis),
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
storeUrls: toStoreURIRuntime(sthis, dbname),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT(sthis, dbOpts);
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
expect(blockstore.loader).toBeTruthy();
Expand Down Expand Up @@ -408,10 +429,13 @@ describe("Loader with two committed transactions", function () {
await sthis.start();
const dbOpts: DatabaseOpts = {
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, "test-loader"),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT(sthis, dbOpts);
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
expect(blockstore.loader).toBeTruthy();
Expand Down Expand Up @@ -464,10 +488,13 @@ describe("Loader with many committed transactions", function () {
await sthis.start();
const dbOpts: DatabaseOpts = {
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, "test-loader-many"),
storeEnDe: bs.ensureStoreEnDeFile({})
}
storeEnDe: bs.ensureStoreEnDeFile({}),
};
crdt = new CRDT(sthis, dbOpts);
blockstore = crdt.blockstore as bs.EncryptedBlockstore;
expect(blockstore.loader).toBeTruthy();
Expand Down
8 changes: 4 additions & 4 deletions tests/fireproof/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("basic Database with record", function () {
});
beforeEach(async function () {
await sthis.start();
db = Database.factory();
db = Database.factory("factory-name");
const ok = await db.put<Doc>({ _id: "hello", value: "world" });
expect(ok.id).toBe("hello");
});
Expand Down Expand Up @@ -83,7 +83,7 @@ describe("basic Database with record", function () {
expect(rows[0].value._id).toBe("hello");
});
it("is not persisted", async function () {
const db2 = Database.factory();
const db2 = Database.factory("factory-name");
const { rows } = await db2.changes([]);
expect(rows.length).toBe(0);
const doc = await db2.get("hello").catch((e) => e);
Expand Down Expand Up @@ -312,7 +312,7 @@ describe("basic Database with subscription", function () {
});
beforeEach(async function () {
await sthis.start();
db = Database.factory();
db = Database.factory("factory-name");
didRun = 0;
waitForSub = new Promise((resolve) => {
unsubscribe = db.subscribe((docs) => {
Expand Down Expand Up @@ -356,7 +356,7 @@ describe("basic Database with no update subscription", function () {
});
beforeEach(async function () {
await sthis.start();
db = Database.factory();
db = Database.factory("factory-name");
didRun = 0;

unsubscribe = db.subscribe(() => {
Expand Down
3 changes: 3 additions & 0 deletions tests/fireproof/indexer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ describe("basic Index upon cold start", function () {
await sthis.start();
dbOpts = {
// meta: opts?.meta,
factoryUnreg() {
return Promise.resolve();
},
keyBag: rt.kb.defaultKeyBagOpts(sthis),
storeUrls: toStoreURIRuntime(sthis, "test-indexer-cold"),
storeEnDe: bs.ensureStoreEnDeFile({})
Expand Down

0 comments on commit f9e4ec1

Please sign in to comment.