mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
feat: Add better support for non-native errors
This commit is contained in:
@@ -20,7 +20,6 @@ import { NotImplementedHttpError } from '../../../src/util/errors/NotImplemented
|
||||
import type { Guarded } from '../../../src/util/GuardedStream';
|
||||
import { SingleRootIdentifierStrategy } from '../../../src/util/identifiers/SingleRootIdentifierStrategy';
|
||||
import { trimTrailingSlashes } from '../../../src/util/PathUtil';
|
||||
import * as quadUtil from '../../../src/util/QuadUtil';
|
||||
import { guardedStreamFrom } from '../../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE, SOLID_HTTP, LDP, PIM, RDF } from '../../../src/util/Vocabularies';
|
||||
import quad = DataFactory.quad;
|
||||
@@ -236,16 +235,6 @@ describe('A DataAccessorBasedStore', (): void => {
|
||||
await expect(store.addResource(resourceID, representation)).rejects.toThrow(BadRequestHttpError);
|
||||
});
|
||||
|
||||
it('passes the result along if the MetadataController throws a non-Error.', async(): Promise<void> => {
|
||||
const resourceID = { path: root };
|
||||
const mock = jest.spyOn(quadUtil, 'parseQuads').mockImplementationOnce(async(): Promise<any> => {
|
||||
throw 'apple';
|
||||
});
|
||||
representation.metadata.add(RDF.type, LDP.terms.Container);
|
||||
await expect(store.addResource(resourceID, representation)).rejects.toBe('apple');
|
||||
mock.mockRestore();
|
||||
});
|
||||
|
||||
it('can write resources.', async(): Promise<void> => {
|
||||
const resourceID = { path: root };
|
||||
representation.metadata.removeAll(RDF.type);
|
||||
@@ -584,7 +573,7 @@ describe('A DataAccessorBasedStore', (): void => {
|
||||
expect(accessor.data[`${root}resource.dummy`]).not.toBeUndefined();
|
||||
expect(logger.error).toHaveBeenCalledTimes(1);
|
||||
expect(logger.error).toHaveBeenLastCalledWith(
|
||||
'Problem deleting auxiliary resource http://test.com/resource.dummy: auxiliary error!',
|
||||
'Error deleting auxiliary resource http://test.com/resource.dummy: auxiliary error!',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -607,7 +596,7 @@ describe('A DataAccessorBasedStore', (): void => {
|
||||
expect(accessor.data[`${root}resource.dummy`]).not.toBeUndefined();
|
||||
expect(logger.error).toHaveBeenCalledTimes(1);
|
||||
expect(logger.error).toHaveBeenLastCalledWith(
|
||||
'Problem deleting auxiliary resource http://test.com/resource.dummy: auxiliary error!',
|
||||
'Error deleting auxiliary resource http://test.com/resource.dummy: Unknown error: auxiliary error!',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
getBestPreference,
|
||||
getConversionTarget,
|
||||
getTypeWeight,
|
||||
getWeightedPreferences,
|
||||
getWeightedPreferences, isInternalContentType,
|
||||
matchesMediaPreferences,
|
||||
matchesMediaType,
|
||||
} from '../../../../src/storage/conversion/ConversionUtil';
|
||||
@@ -144,4 +144,13 @@ describe('ConversionUtil', (): void => {
|
||||
expect(matchesMediaType('text/plain', 'text/turtle')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isInternalContentType', (): void => {
|
||||
it('only returns true on internal types.', async(): Promise<void> => {
|
||||
expect(isInternalContentType('internal/quads')).toBeTruthy();
|
||||
|
||||
expect(isInternalContentType()).toBeFalsy();
|
||||
expect(isInternalContentType('text/turtle')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user