mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Fix test issues
The root container wasn't being created for file based tests. Containers should be POSTed as RDF bodies. Containment triples of child containers had no trailing slash.
This commit is contained in:
@@ -6,7 +6,12 @@ import { APPLICATION_OCTET_STREAM, TEXT_TURTLE } from '../util/ContentTypes';
|
||||
import { ConflictHttpError } from '../util/errors/ConflictHttpError';
|
||||
import { NotFoundHttpError } from '../util/errors/NotFoundHttpError';
|
||||
import { UnsupportedHttpError } from '../util/errors/UnsupportedHttpError';
|
||||
import { decodeUriPathComponents, encodeUriPathComponents, trimTrailingSlashes } from '../util/Util';
|
||||
import {
|
||||
decodeUriPathComponents,
|
||||
encodeUriPathComponents,
|
||||
ensureTrailingSlash,
|
||||
trimTrailingSlashes,
|
||||
} from '../util/Util';
|
||||
import type { FileIdentifierMapper, ResourceLink } from './FileIdentifierMapper';
|
||||
|
||||
const { join: joinPath, normalize: normalizePath } = posix;
|
||||
@@ -137,7 +142,7 @@ export class ExtensionBasedMapper implements FileIdentifierMapper {
|
||||
let relative = filePath.slice(this.rootFilepath.length);
|
||||
if (isContainer) {
|
||||
return {
|
||||
identifier: { path: this.baseRequestURI + encodeUriPathComponents(relative) },
|
||||
identifier: { path: ensureTrailingSlash(this.baseRequestURI + encodeUriPathComponents(relative)) },
|
||||
filePath,
|
||||
};
|
||||
}
|
||||
@@ -150,7 +155,7 @@ export class ExtensionBasedMapper implements FileIdentifierMapper {
|
||||
}
|
||||
|
||||
return {
|
||||
identifier: { path: this.baseRequestURI + encodeUriPathComponents(relative) },
|
||||
identifier: { path: trimTrailingSlashes(this.baseRequestURI + encodeUriPathComponents(relative)) },
|
||||
filePath,
|
||||
contentType,
|
||||
};
|
||||
|
||||
@@ -195,7 +195,7 @@ export class FileResourceStore implements ResourceStore {
|
||||
const files = await fsPromises.readdir(path);
|
||||
const match = files.find((file): any => !file.startsWith('.metadata'));
|
||||
if (typeof match === 'string') {
|
||||
throw new ConflictHttpError('Container is not empty.');
|
||||
throw new ConflictHttpError('Can only delete empty containers.');
|
||||
}
|
||||
|
||||
// Only delete the metadata file as auxiliary resource because this is the only file created by this store.
|
||||
|
||||
Reference in New Issue
Block a user