Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aryanjassal committed Nov 27, 2024
1 parent ddc512e commit 10e9ff2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/client/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ErrorClientAuthDenied<T> extends ErrorClient<T> {
}

class ErrorClientInvalidHeader<T> extends ErrorClient<T> {
static description = 'The header message does not match the expected type'
static description = 'The header message does not match the expected type';
exitCode = sysexits.USAGE;
}

Expand Down
5 changes: 3 additions & 2 deletions src/client/handlers/VaultsSecretsRemove.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { DB } from '@matrixai/db';
import type { ResourceAcquire } from '@matrixai/resources';
import type {
ClientRPCRequestParams,
ClientRPCResponseResult,
Expand All @@ -7,9 +8,9 @@ import type {
SuccessOrErrorMessage,
} from '../types';
import type VaultManager from '../../vaults/VaultManager';
import { ResourceAcquire, withG } from '@matrixai/resources';
import type { FileSystemWritable } from '../../vaults/types';
import { withG } from '@matrixai/resources';
import { DuplexHandler } from '@matrixai/rpc';
import { FileSystemWritable } from '../../vaults/types';
import * as vaultsUtils from '../../vaults/utils';
import * as vaultsErrors from '../../vaults/errors';
import * as clientErrors from '../errors';
Expand Down
3 changes: 1 addition & 2 deletions src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ type JSONRPCResponseResult<
> = T & {
metadata?: JSONRPCResponseMetadata &
M &
(T extends { metadata: infer U } ? U : {}) &
JSONObject;
(T extends { metadata: infer U } ? U : JSONObject);
};

type ClientRPCRequestParams<T extends JSONObject = JSONObject> =
Expand Down
4 changes: 2 additions & 2 deletions src/vaults/VaultInternal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ class VaultInternal {
return async () => {
let releaseTran: ResourceRelease | undefined = undefined;
const acquire = this.lock.write();
const [release] = await acquire([tran]);
const [release] = await acquire();
if (tran == null) {
const acquireTran = this.db.transaction();
[releaseTran, tran] = await acquireTran();
Expand All @@ -590,7 +590,7 @@ class VaultInternal {
);
return [
async (e?: Error) => {
if (e != null) {
if (e == null) {
try {
// After doing mutation we need to commit the new history
await this.createCommit();
Expand Down
8 changes: 1 addition & 7 deletions tests/client/handlers/vaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import type { FileSystem } from '@/types';
import type { VaultId } from '@/ids';
import type NodeManager from '@/nodes/NodeManager';
import type {
ContentSuccessMessage,
ErrorMessage,
LogEntryMessage,
SecretContentMessage,
VaultListMessage,
Expand Down Expand Up @@ -75,7 +73,6 @@ import * as vaultsErrors from '@/vaults/errors';
import * as networkUtils from '@/network/utils';
import * as utils from '@/utils';
import * as testsUtils from '../../utils';
import { error } from 'console';

describe('vaultsClone', () => {
const logger = new Logger('vaultsClone test', LogLevel.WARN, [
Expand Down Expand Up @@ -1731,7 +1728,7 @@ describe('vaultsSecretsCat', () => {
// Read response
for await (const data of response.readable) {
expect(data.type).toEqual('success');
if (data.type !== 'success') utils.never()
if (data.type !== 'success') utils.never();
expect(data.secretContent).toEqual(secretContent);
}
});
Expand Down Expand Up @@ -2530,7 +2527,6 @@ describe('vaultsSecretsRemove', () => {
// Get log size
let logLength = 0;
await vaultManager.withVaults([vaultId], async (vault) => {
console.log(await vault.log())
logLength = (await vault.log()).length;
});
// Delete secret
Expand All @@ -2557,12 +2553,10 @@ describe('vaultsSecretsRemove', () => {
for await (const data of response.readable) {
loopRun = true;
expect(data.type).toStrictEqual('success');
console.log(data.type);
}
expect(loopRun).toBeTruthy();
// Ensure single log message for deleting the secrets
await vaultManager.withVaults([vaultId], async (vault) => {
console.log(await vault.log())
expect((await vault.log()).length).toEqual(logLength + 1);
});
});
Expand Down

0 comments on commit 10e9ff2

Please sign in to comment.