Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
fix: increase coverage levels.
Browse files Browse the repository at this point in the history
  • Loading branch information
elribonazo committed Jan 8, 2024
1 parent 7dc013a commit 9f219d0
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 35 deletions.
12 changes: 2 additions & 10 deletions packages/database/coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
{"total": {"lines":{"total":207,"covered":207,"skipped":0,"pct":100},"statements":{"total":218,"covered":218,"skipped":0,"pct":100},"functions":{"total":77,"covered":77,"skipped":0,"pct":100},"branches":{"total":72,"covered":72,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/index.ts": {"lines":{"total":153,"covered":153,"skipped":0,"pct":100},"functions":{"total":67,"covered":67,"skipped":0,"pct":100},"statements":{"total":164,"covered":164,"skipped":0,"pct":100},"branches":{"total":50,"covered":50,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/schemas/Credential.ts": {"lines":{"total":11,"covered":11,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":11,"covered":11,"skipped":0,"pct":100},"branches":{"total":4,"covered":4,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/schemas/CredentialRequestMetadata.ts": {"lines":{"total":3,"covered":3,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/schemas/DID.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/schemas/DIDPair.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/schemas/LinkSecret.ts": {"lines":{"total":3,"covered":3,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/schemas/Mediator.ts": {"lines":{"total":4,"covered":4,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":4,"covered":4,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/schemas/Message.ts": {"lines":{"total":3,"covered":3,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":3,"covered":3,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/database/src/schemas/PrivateKey.ts": {"lines":{"total":28,"covered":28,"skipped":0,"pct":100},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":28,"covered":28,"skipped":0,"pct":100},"branches":{"total":18,"covered":18,"skipped":0,"pct":100}}
{"total": {"lines":{"total":31,"covered":31,"skipped":0,"pct":100},"statements":{"total":31,"covered":31,"skipped":0,"pct":100},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"branches":{"total":18,"covered":18,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":"Unknown"}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/database/src/index.ts": {"lines":{"total":31,"covered":31,"skipped":0,"pct":100},"functions":{"total":5,"covered":5,"skipped":0,"pct":100},"statements":{"total":31,"covered":31,"skipped":0,"pct":100},"branches":{"total":18,"covered":18,"skipped":0,"pct":100}}
}
6 changes: 2 additions & 4 deletions packages/database/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ export const Database = {
const staticMethodModels = Object.keys(target.db.collections).reduce<Map<string, Function>>((statics, collectionName) => {
const currentCollection: RxCollection = target.db.collections[collectionName];
Object.keys(currentCollection.statics).forEach((staticName) => {
const func = currentCollection.statics[staticName];
const func = currentCollection.statics[staticName]!;
if (statics.has(staticName)) {
throw new Error(`Static function in model ${collectionName}.${staticName} is duplicated, statics must be unique across al collections.`)
}
if (func && typeof func === "function") {
statics.set(staticName, func)
}
statics.set(staticName, func)
})
return statics
}, new Map<string, Function>())
Expand Down
84 changes: 84 additions & 0 deletions packages/database/tests/pluto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,90 @@ describe("Pluto encrypted testing with different storages", () => {

})

it(storageName + "Should allow anyone to add new models to the database without using the same models", async ({ expect }) => {
const forceDatabaseName = `${databaseName}${randomUUID()}`

const db = await Database.createEncrypted<{
demo: RxCollection<
LinkSecretSchemaType,
LinkSecretMethodTypes,
{ hola: (demo: boolean, demo2: boolean) => void }
>
}>(
{
name: forceDatabaseName,
encryptionKey: defaultPassword,
storage,
withDefaultCollections: false,
collections: {
demo: {
methods: LinkSecretMethods,
schema: LinkSecretSchema,
statics: {
hola: function (demo: boolean, demo2: boolean): void {
throw new Error('Function not implemented.')
}
}
}
}
}
);

expect(db.db.collections.demo).to.not.toBeUndefined();
expect(db.db.collections.demo.hola).to.not.toBeUndefined();


})

it(storageName + "Should allow anyone to add new models to the database without using the same models", async ({ expect }) => {
const forceDatabaseName = `${databaseName}${randomUUID()}`


await expect(() => Database.createEncrypted<{
demo: RxCollection<
LinkSecretSchemaType,
LinkSecretMethodTypes,
{ hola: (demo: boolean, demo2: boolean) => void }
>,
demo2: RxCollection<
LinkSecretSchemaType,
LinkSecretMethodTypes,
{ hola: (demo: boolean, demo2: boolean) => void }
>
}>(
{
name: forceDatabaseName,
encryptionKey: defaultPassword,
storage,
withDefaultCollections: false,
collections: {
demo: {
methods: LinkSecretMethods,
schema: LinkSecretSchema,
statics: {
hola: function (demo: boolean, demo2: boolean): void {
throw new Error('Function not implemented.')
}
}
},
demo2: {
methods: LinkSecretMethods,
schema: LinkSecretSchema,
statics: {
hola: function (demo: boolean, demo2: boolean): void {
throw new Error('Function not implemented.')
}
}
}
}
}
)).rejects.toThrowError(new Error("Static function in model demo2.hola is duplicated, statics must be unique across al collections."));


})



});
})
})
10 changes: 5 additions & 5 deletions packages/indexdb/coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{"total": {"lines":{"total":236,"covered":221,"skipped":0,"pct":93.64},"statements":{"total":246,"covered":228,"skipped":0,"pct":92.68},"functions":{"total":56,"covered":53,"skipped":0,"pct":94.64},"branches":{"total":105,"covered":84,"skipped":0,"pct":80},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/indexdb/src/index.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/indexdb/src/storage-dexie/dexie-helper.ts": {"lines":{"total":95,"covered":86,"skipped":0,"pct":90.52},"functions":{"total":22,"covered":21,"skipped":0,"pct":95.45},"statements":{"total":100,"covered":90,"skipped":0,"pct":90},"branches":{"total":48,"covered":39,"skipped":0,"pct":81.25}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/indexdb/src/storage-dexie/dexie-query.ts": {"lines":{"total":32,"covered":30,"skipped":0,"pct":93.75},"functions":{"total":6,"covered":5,"skipped":0,"pct":83.33},"statements":{"total":35,"covered":32,"skipped":0,"pct":91.42},"branches":{"total":14,"covered":10,"skipped":0,"pct":71.42}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/indexdb/src/storage-dexie/rx-storage-dexie.ts": {"lines":{"total":10,"covered":10,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":10,"covered":10,"skipped":0,"pct":100},"branches":{"total":3,"covered":3,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/indexdb/src/storage-dexie/rx-storage-instance-dexie.ts": {"lines":{"total":98,"covered":94,"skipped":0,"pct":95.91},"functions":{"total":25,"covered":24,"skipped":0,"pct":96},"statements":{"total":100,"covered":95,"skipped":0,"pct":95},"branches":{"total":40,"covered":32,"skipped":0,"pct":80}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/index.ts": {"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"functions":{"total":0,"covered":0,"skipped":0,"pct":100},"statements":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/dexie-helper.ts": {"lines":{"total":95,"covered":86,"skipped":0,"pct":90.52},"functions":{"total":22,"covered":21,"skipped":0,"pct":95.45},"statements":{"total":100,"covered":90,"skipped":0,"pct":90},"branches":{"total":48,"covered":39,"skipped":0,"pct":81.25}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/dexie-query.ts": {"lines":{"total":32,"covered":30,"skipped":0,"pct":93.75},"functions":{"total":6,"covered":5,"skipped":0,"pct":83.33},"statements":{"total":35,"covered":32,"skipped":0,"pct":91.42},"branches":{"total":14,"covered":10,"skipped":0,"pct":71.42}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/rx-storage-dexie.ts": {"lines":{"total":10,"covered":10,"skipped":0,"pct":100},"functions":{"total":3,"covered":3,"skipped":0,"pct":100},"statements":{"total":10,"covered":10,"skipped":0,"pct":100},"branches":{"total":3,"covered":3,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/indexdb/src/storage-dexie/rx-storage-instance-dexie.ts": {"lines":{"total":98,"covered":94,"skipped":0,"pct":95.91},"functions":{"total":25,"covered":24,"skipped":0,"pct":96},"statements":{"total":100,"covered":95,"skipped":0,"pct":95},"branches":{"total":40,"covered":32,"skipped":0,"pct":80}}
}
6 changes: 3 additions & 3 deletions packages/inmemory/coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"total": {"lines":{"total":147,"covered":143,"skipped":0,"pct":97.27},"statements":{"total":153,"covered":148,"skipped":0,"pct":96.73},"functions":{"total":28,"covered":27,"skipped":0,"pct":96.42},"branches":{"total":53,"covered":43,"skipped":0,"pct":81.13},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/inmemory/src/index.ts": {"lines":{"total":12,"covered":12,"skipped":0,"pct":100},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":12,"covered":12,"skipped":0,"pct":100},"branches":{"total":5,"covered":5,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/inmemory/src/inMemoryStorage/instance.ts": {"lines":{"total":93,"covered":89,"skipped":0,"pct":95.69},"functions":{"total":15,"covered":14,"skipped":0,"pct":93.33},"statements":{"total":98,"covered":93,"skipped":0,"pct":94.89},"branches":{"total":34,"covered":24,"skipped":0,"pct":70.58}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/inmemory/src/inMemoryStorage/internal.ts": {"lines":{"total":42,"covered":42,"skipped":0,"pct":100},"functions":{"total":11,"covered":11,"skipped":0,"pct":100},"statements":{"total":43,"covered":43,"skipped":0,"pct":100},"branches":{"total":14,"covered":14,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/inmemory/src/index.ts": {"lines":{"total":12,"covered":12,"skipped":0,"pct":100},"functions":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":12,"covered":12,"skipped":0,"pct":100},"branches":{"total":5,"covered":5,"skipped":0,"pct":100}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/inmemory/src/inMemoryStorage/instance.ts": {"lines":{"total":93,"covered":89,"skipped":0,"pct":95.69},"functions":{"total":15,"covered":14,"skipped":0,"pct":93.33},"statements":{"total":98,"covered":93,"skipped":0,"pct":94.89},"branches":{"total":34,"covered":24,"skipped":0,"pct":70.58}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/inmemory/src/inMemoryStorage/internal.ts": {"lines":{"total":42,"covered":42,"skipped":0,"pct":100},"functions":{"total":11,"covered":11,"skipped":0,"pct":100},"statements":{"total":43,"covered":43,"skipped":0,"pct":100},"branches":{"total":14,"covered":14,"skipped":0,"pct":100}}
}
6 changes: 3 additions & 3 deletions packages/leveldb/coverage/coverage-summary.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{"total": {"lines":{"total":200,"covered":189,"skipped":0,"pct":94.5},"statements":{"total":207,"covered":195,"skipped":0,"pct":94.2},"functions":{"total":51,"covered":48,"skipped":0,"pct":94.11},"branches":{"total":68,"covered":51,"skipped":0,"pct":75},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/leveldb/src/index.ts": {"lines":{"total":19,"covered":19,"skipped":0,"pct":100},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":19,"covered":19,"skipped":0,"pct":100},"branches":{"total":8,"covered":6,"skipped":0,"pct":75}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/leveldb/src/leveldb/instance.ts": {"lines":{"total":93,"covered":89,"skipped":0,"pct":95.69},"functions":{"total":16,"covered":15,"skipped":0,"pct":93.75},"statements":{"total":99,"covered":94,"skipped":0,"pct":94.94},"branches":{"total":30,"covered":22,"skipped":0,"pct":73.33}}
,"/home/runner/work/pluto-encrypted/pluto-encrypted/packages/leveldb/src/leveldb/internal.ts": {"lines":{"total":88,"covered":81,"skipped":0,"pct":92.04},"functions":{"total":31,"covered":29,"skipped":0,"pct":93.54},"statements":{"total":89,"covered":82,"skipped":0,"pct":92.13},"branches":{"total":30,"covered":23,"skipped":0,"pct":76.66}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/leveldb/src/index.ts": {"lines":{"total":19,"covered":19,"skipped":0,"pct":100},"functions":{"total":4,"covered":4,"skipped":0,"pct":100},"statements":{"total":19,"covered":19,"skipped":0,"pct":100},"branches":{"total":8,"covered":6,"skipped":0,"pct":75}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/leveldb/src/leveldb/instance.ts": {"lines":{"total":93,"covered":89,"skipped":0,"pct":95.69},"functions":{"total":16,"covered":15,"skipped":0,"pct":93.75},"statements":{"total":99,"covered":94,"skipped":0,"pct":94.94},"branches":{"total":30,"covered":22,"skipped":0,"pct":73.33}}
,"/Users/ribo/Projects/personal/pluto-encrypted/packages/leveldb/src/leveldb/internal.ts": {"lines":{"total":88,"covered":81,"skipped":0,"pct":92.04},"functions":{"total":31,"covered":29,"skipped":0,"pct":93.54},"statements":{"total":89,"covered":82,"skipped":0,"pct":92.13},"branches":{"total":30,"covered":23,"skipped":0,"pct":76.66}}
}
Loading

0 comments on commit 9f219d0

Please sign in to comment.