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:
Joachim Van Herwegen
2020-09-23 17:03:42 +02:00
parent e85ca622da
commit 22962192ff
5 changed files with 17 additions and 9 deletions

View File

@@ -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,
};

View File

@@ -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.