feat: Move runtime config into dedicated component, Closes #67

* Move runtime config into dedicated component, Closes #67

* Migrate FileResourceStore to RuntimeConfig
This commit is contained in:
Ruben Taelman
2020-08-26 10:25:47 +02:00
committed by GitHub
parent 4f8ebff7f7
commit 5126356c94
14 changed files with 194 additions and 84 deletions

View File

@@ -13,6 +13,7 @@ import { QuadToTurtleConverter } from '../../src/storage/conversion/QuadToTurtle
import { Representation } from '../../src/ldp/representation/Representation';
import { RepresentationConvertingStore } from '../../src/storage/RepresentationConvertingStore';
import { ResponseDescription } from '../../src/ldp/operations/ResponseDescription';
import { RuntimeConfig } from '../../src/init/RuntimeConfig';
import { SimpleAuthorizer } from '../../src/authorization/SimpleAuthorizer';
import { SimpleBodyParser } from '../../src/ldp/http/SimpleBodyParser';
import { SimpleCredentialsExtractor } from '../../src/authentication/SimpleCredentialsExtractor';
@@ -44,7 +45,7 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
const permissionsExtractor = new BasePermissionsExtractor();
const authorizer = new SimpleAuthorizer();
const store = new SimpleResourceStore('http://test.com/');
const store = new SimpleResourceStore(new RuntimeConfig({ base: 'http://test.com/' }));
const operationHandler = new CompositeAsyncHandler<Operation, ResponseDescription>([
new SimpleGetOperationHandler(store),
new SimplePostOperationHandler(store),
@@ -115,7 +116,7 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
]);
const authorizer = new SimpleAuthorizer();
const store = new SimpleResourceStore('http://test.com/');
const store = new SimpleResourceStore(new RuntimeConfig({ base: 'http://test.com/' }));
const converter = new CompositeAsyncHandler([
new QuadToTurtleConverter(),
new TurtleToQuadConverter(),

View File

@@ -12,6 +12,7 @@ import { QuadToTurtleConverter } from '../../src/storage/conversion/QuadToTurtle
import { RepresentationConvertingStore } from '../../src/storage/RepresentationConvertingStore';
import { ResourceStore } from '../../src/storage/ResourceStore';
import { ResponseDescription } from '../../src/ldp/operations/ResponseDescription';
import { RuntimeConfig } from '../../src/init/RuntimeConfig';
import { SimpleAclAuthorizer } from '../../src/authorization/SimpleAclAuthorizer';
import { SimpleBodyParser } from '../../src/ldp/http/SimpleBodyParser';
import { SimpleCredentialsExtractor } from '../../src/authentication/SimpleCredentialsExtractor';
@@ -80,7 +81,7 @@ describe('A server with authorization', (): void => {
bodyParser,
});
const store = new SimpleResourceStore('http://test.com/');
const store = new SimpleResourceStore(new RuntimeConfig({ base: 'http://test.com/' }));
const converter = new CompositeAsyncHandler([
new QuadToTurtleConverter(),
new TurtleToQuadConverter(),
@@ -91,7 +92,7 @@ describe('A server with authorization', (): void => {
const permissionsExtractor = new BasePermissionsExtractor();
const authorizer = new SimpleAclAuthorizer(
new SimpleExtensionAclManager(),
new UrlContainerManager('http://test.com/'),
new UrlContainerManager(new RuntimeConfig({ base: 'http://test.com/' })),
convertingStore,
);

View File

@@ -0,0 +1,43 @@
import { RuntimeConfig } from '../../../src/init/RuntimeConfig';
describe('RuntimeConfig', (): void => {
it('handles undefined args.', async(): Promise<void> => {
const config = new RuntimeConfig();
expect(config.port).toEqual(3000);
expect(config.base).toEqual('http://localhost:3000/');
});
it('handles empty args.', async(): Promise<void> => {
const config = new RuntimeConfig({});
expect(config.port).toEqual(3000);
expect(config.base).toEqual('http://localhost:3000/');
});
it('handles args with port.', async(): Promise<void> => {
const config = new RuntimeConfig({ port: 1234 });
expect(config.port).toEqual(1234);
expect(config.base).toEqual('http://localhost:1234/');
});
it('handles args with base.', async(): Promise<void> => {
const config = new RuntimeConfig({ base: 'http://example.org/' });
expect(config.port).toEqual(3000);
expect(config.base).toEqual('http://example.org/');
});
it('handles args with port and base.', async(): Promise<void> => {
const config = new RuntimeConfig({ port: 1234, base: 'http://example.org/' });
expect(config.port).toEqual(1234);
expect(config.base).toEqual('http://example.org/');
});
it('handles resetting data.', async(): Promise<void> => {
const config = new RuntimeConfig({});
expect(config.port).toEqual(3000);
expect(config.base).toEqual('http://localhost:3000/');
config.reset({ port: 1234, base: 'http://example.org/' });
expect(config.port).toEqual(1234);
expect(config.base).toEqual('http://example.org/');
});
});

View File

@@ -1,3 +1,4 @@
import { RuntimeConfig } from '../../../src/init/RuntimeConfig';
import { Setup } from '../../../src/init/Setup';
describe('Setup', (): void => {
@@ -15,16 +16,16 @@ describe('Setup', (): void => {
httpServer = {
listen: jest.fn(),
};
setup = new Setup(httpServer, store, aclManager);
setup = new Setup(httpServer, store, aclManager, new RuntimeConfig());
});
it('starts an HTTP server.', async(): Promise<void> => {
await setup.setup(3000, 'http://localhost:3000/');
await setup.setup();
expect(httpServer.listen).toHaveBeenCalledWith(3000);
});
it('invokes ACL initialization.', async(): Promise<void> => {
await setup.setup(3000, 'http://localhost:3000/');
await setup.setup();
expect(aclManager.getAcl).toHaveBeenCalledWith({ path: 'http://localhost:3000/' });
expect(store.setRepresentation).toHaveBeenCalledTimes(1);
});

View File

@@ -10,6 +10,7 @@ import { NotFoundHttpError } from '../../../src/util/errors/NotFoundHttpError';
import { posix } from 'path';
import { Readable } from 'stream';
import { RepresentationMetadata } from '../../../src/ldp/representation/RepresentationMetadata';
import { RuntimeConfig } from '../../../src/init/RuntimeConfig';
import streamifyArray from 'streamify-array';
import { UnsupportedMediaTypeHttpError } from '../../../src/util/errors/UnsupportedMediaTypeHttpError';
import { CONTENT_TYPE_QUADS, DATA_TYPE_BINARY, DATA_TYPE_QUAD } from '../../../src/util/ContentTypes';
@@ -21,7 +22,7 @@ import { literal, namedNode, quad as quadRDF, triple } from '@rdfjs/data-model';
const { join: joinPath } = posix;
const base = 'http://test.com/';
const root = '/Users/default/home/public/';
const rootFilepath = '/Users/default/home/public/';
fsPromises.rmdir = jest.fn();
fsPromises.lstat = jest.fn();
@@ -48,7 +49,11 @@ describe('A FileResourceStore', (): void => {
beforeEach(async(): Promise<void> => {
jest.clearAllMocks();
store = new FileResourceStore(base, root, new InteractionController(), new MetadataController());
store = new FileResourceStore(
new RuntimeConfig({ base, rootFilepath }),
new InteractionController(),
new MetadataController(),
);
representation = {
data: streamifyArray([ rawData ]),
@@ -131,7 +136,7 @@ describe('A FileResourceStore', (): void => {
// Write container (POST)
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDP_BC ]) }, slug: 'myContainer/', raw: []};
const identifier = await store.addResource({ path: base }, representation);
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(root, 'myContainer/'), { recursive: true });
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'myContainer/'), { recursive: true });
expect(identifier.path).toBe(`${base}myContainer/`);
// Read container
@@ -155,7 +160,7 @@ describe('A FileResourceStore', (): void => {
// Tests
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDP_BC ]) }, slug: 'myContainer/', raw: []};
await expect(store.addResource({ path: `${base}foo` }, representation)).rejects.toThrow(MethodNotAllowedHttpError);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'foo'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo'));
});
it('errors 405 for POST invalid path ending without slash.', async(): Promise<void> => {
@@ -172,17 +177,17 @@ describe('A FileResourceStore', (): void => {
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDP_BC ]) }, slug: 'myContainer/', raw: []};
await expect(store.addResource({ path: `${base}doesnotexist` }, representation))
.rejects.toThrow(MethodNotAllowedHttpError);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'doesnotexist'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'doesnotexist'));
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDPR ]) }, slug: 'file.txt', raw: []};
await expect(store.addResource({ path: `${base}doesnotexist` }, representation))
.rejects.toThrow(MethodNotAllowedHttpError);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'doesnotexist'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'doesnotexist'));
representation.metadata = { linkRel: { type: new Set() }, slug: 'file.txt', raw: []};
await expect(store.addResource({ path: `${base}existingresource` }, representation))
.rejects.toThrow(MethodNotAllowedHttpError);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'existingresource'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'existingresource'));
});
it('can set data.', async(): Promise<void> => {
@@ -204,7 +209,7 @@ describe('A FileResourceStore', (): void => {
// Tests
await store.setRepresentation({ path: `${base}file.txt` }, representation);
expect(fs.createWriteStream as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt'));
expect(fs.createWriteStream as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt'));
const result = await store.getRepresentation({ path: `${base}file.txt` });
expect(result).toEqual({
dataType: DATA_TYPE_BINARY,
@@ -217,9 +222,9 @@ describe('A FileResourceStore', (): void => {
},
});
await expect(arrayifyStream(result.data)).resolves.toEqual([ rawData ]);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt'));
expect(fs.createReadStream as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt'));
expect(fs.createReadStream as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt.metadata'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt'));
expect(fs.createReadStream as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt'));
expect(fs.createReadStream as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt.metadata'));
});
it('can delete data.', async(): Promise<void> => {
@@ -239,7 +244,7 @@ describe('A FileResourceStore', (): void => {
// Tests
await store.deleteResource({ path: `${base}file.txt` });
expect(fsPromises.unlink as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt'));
expect(fsPromises.unlink as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt'));
await expect(store.getRepresentation({ path: `${base}file.txt` })).rejects.toThrow(NotFoundHttpError);
});
@@ -253,8 +258,9 @@ describe('A FileResourceStore', (): void => {
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDPR ]) }, slug: 'file.txt', raw: []};
const identifier = await store.addResource({ path: `${base}doesnotexistyet/` }, representation);
expect(identifier.path).toBe(`${base}doesnotexistyet/file.txt`);
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(root, 'doesnotexistyet/'), { recursive: true });
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'doesnotexistyet/'));
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'doesnotexistyet/'),
{ recursive: true });
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'doesnotexistyet/'));
});
it('creates metadata file when metadata triples are passed.', async(): Promise<void> => {
@@ -277,8 +283,8 @@ describe('A FileResourceStore', (): void => {
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDPR ]) }, raw: [ quad ]};
representation.data = readableMock;
await store.addResource({ path: `${base}foo/` }, representation);
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(root, 'foo/'), { recursive: true });
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'foo/'));
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo/'), { recursive: true });
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo/'));
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDPR ]) }, raw: [ quad ]};
await store.setRepresentation({ path: `${base}foo/file.txt` }, representation);
@@ -298,8 +304,8 @@ describe('A FileResourceStore', (): void => {
// Tests
await expect(store.deleteResource({ path: `${base}notempty/` })).rejects.toThrow(ConflictHttpError);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'notempty/'));
expect(fsPromises.readdir as jest.Mock).toBeCalledWith(joinPath(root, 'notempty/'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'notempty/'));
expect(fsPromises.readdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'notempty/'));
});
it('deletes metadata file when deleting container.', async(): Promise<void> => {
@@ -312,10 +318,10 @@ describe('A FileResourceStore', (): void => {
// Tests
await store.deleteResource({ path: `${base}foo/` });
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'foo/'));
expect(fsPromises.readdir as jest.Mock).toBeCalledWith(joinPath(root, 'foo/'));
expect(fsPromises.unlink as jest.Mock).toBeCalledWith(joinPath(root, 'foo', '.metadata'));
expect(fsPromises.rmdir as jest.Mock).toBeCalledWith(joinPath(root, 'foo/'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo/'));
expect(fsPromises.readdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo/'));
expect(fsPromises.unlink as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo', '.metadata'));
expect(fsPromises.rmdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo/'));
});
it('errors 404 when accessing non resource (file/directory), e.g. special files.', async(): Promise<void> => {
@@ -368,10 +374,10 @@ describe('A FileResourceStore', (): void => {
},
});
await expect(arrayifyStream(result.data)).resolves.toEqualRdfQuadArray(quads);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'foo/'));
expect(fsPromises.readdir as jest.Mock).toBeCalledWith(joinPath(root, 'foo/'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'foo', 'file.txt'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'foo', '.nonresource'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo/'));
expect(fsPromises.readdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo/'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo', 'file.txt'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo', '.nonresource'));
});
it('can overwrite representation with PUT.', async(): Promise<void> => {
@@ -387,8 +393,8 @@ describe('A FileResourceStore', (): void => {
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDPR ]) }, raw: []};
await store.setRepresentation({ path: `${base}alreadyexists.txt` }, representation);
expect(fs.createWriteStream as jest.Mock).toBeCalledTimes(1);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'alreadyexists.txt'));
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(root, { recursive: true });
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'alreadyexists.txt'));
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(rootFilepath, { recursive: true });
});
it('errors when overwriting container with PUT.', async(): Promise<void> => {
@@ -399,7 +405,7 @@ describe('A FileResourceStore', (): void => {
// Tests
await expect(store.setRepresentation({ path: `${base}alreadyexists` }, representation)).rejects
.toThrow(ConflictHttpError);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'alreadyexists'));
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'alreadyexists'));
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDP_BC ]) }, raw: []};
await expect(store.setRepresentation({ path: `${base}alreadyexists/` }, representation)).rejects
.toThrow(ConflictHttpError);
@@ -445,9 +451,9 @@ describe('A FileResourceStore', (): void => {
// Tests
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDPR ]) }, slug: 'file.txt', raw: [ quad ]};
await expect(store.addResource({ path: base }, representation)).rejects.toThrow(Error);
expect(fs.createWriteStream as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt.metadata'));
expect(fs.createWriteStream as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt'));
expect(fsPromises.unlink as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt.metadata'));
expect(fs.createWriteStream as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt.metadata'));
expect(fs.createWriteStream as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt'));
expect(fsPromises.unlink as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt.metadata'));
});
it('undoes container creation when metadata file creation fails.', async(): Promise<void> => {
@@ -461,7 +467,7 @@ describe('A FileResourceStore', (): void => {
// Tests
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDP_BC ]) }, slug: 'foo/', raw: [ quad ]};
await expect(store.addResource({ path: base }, representation)).rejects.toThrow(Error);
expect(fsPromises.rmdir as jest.Mock).toBeCalledWith(joinPath(root, 'foo/'));
expect(fsPromises.rmdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo/'));
});
it('creates container when POSTing without linkRel and with slug ending with slash.', async(): Promise<void> => {
@@ -474,7 +480,7 @@ describe('A FileResourceStore', (): void => {
const identifier = await store.addResource({ path: base }, representation);
expect(identifier.path).toBe(`${base}myContainer/`);
expect(fsPromises.mkdir as jest.Mock).toBeCalledTimes(1);
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(root, 'myContainer/'), { recursive: true });
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'myContainer/'), { recursive: true });
});
it('returns no contentType when unknown for representation.', async(): Promise<void> => {
@@ -514,9 +520,9 @@ describe('A FileResourceStore', (): void => {
// Tests
representation.metadata = { raw: []};
await store.setRepresentation({ path: `${base}file.txt` }, representation);
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(root, { recursive: true });
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(rootFilepath, { recursive: true });
expect(fs.createWriteStream as jest.Mock).toBeCalledTimes(1);
expect(fs.createWriteStream as jest.Mock).toBeCalledWith(joinPath(root, 'file.txt'));
expect(fs.createWriteStream as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'file.txt'));
});
it('creates container when POST to existing container path ending without slash and slug without slash.',
@@ -530,7 +536,7 @@ describe('A FileResourceStore', (): void => {
representation.metadata = { linkRel: { type: new Set([ LINK_TYPE_LDP_BC ]) }, slug: 'bar', raw: []};
const identifier = await store.addResource({ path: `${base}foo` }, representation);
expect(identifier.path).toBe(`${base}foo/bar/`);
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(root, 'foo'));
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(root, 'foo', 'bar/'), { recursive: false });
expect(fsPromises.lstat as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo'));
expect(fsPromises.mkdir as jest.Mock).toBeCalledWith(joinPath(rootFilepath, 'foo', 'bar/'), { recursive: false });
});
});

View File

@@ -4,6 +4,7 @@ import { DATA_TYPE_BINARY } from '../../../src/util/ContentTypes';
import { NotFoundHttpError } from '../../../src/util/errors/NotFoundHttpError';
import { Readable } from 'stream';
import { RepresentationMetadata } from '../../../src/ldp/representation/RepresentationMetadata';
import { RuntimeConfig } from '../../../src/init/RuntimeConfig';
import { SimpleResourceStore } from '../../../src/storage/SimpleResourceStore';
import streamifyArray from 'streamify-array';
@@ -15,7 +16,7 @@ describe('A SimpleResourceStore', (): void => {
const dataString = '<http://test.com/s> <http://test.com/p> <http://test.com/o>.';
beforeEach(async(): Promise<void> => {
store = new SimpleResourceStore(base);
store = new SimpleResourceStore(new RuntimeConfig({ base }));
representation = {
data: streamifyArray([ dataString ]),

View File

@@ -1,8 +1,9 @@
import { RuntimeConfig } from '../../../src/init/RuntimeConfig';
import { UrlContainerManager } from '../../../src/storage/UrlContainerManager';
describe('An UrlContainerManager', (): void => {
it('returns the parent URl for a single call.', async(): Promise<void> => {
const manager = new UrlContainerManager('http://test.com/foo/');
const manager = new UrlContainerManager(new RuntimeConfig({ base: 'http://test.com/foo/' }));
await expect(manager.getContainer({ path: 'http://test.com/foo/bar' }))
.resolves.toEqual({ path: 'http://test.com/foo/' });
await expect(manager.getContainer({ path: 'http://test.com/foo/bar/' }))
@@ -10,13 +11,13 @@ describe('An UrlContainerManager', (): void => {
});
it('errors when getting the container of root.', async(): Promise<void> => {
let manager = new UrlContainerManager('http://test.com/foo/');
let manager = new UrlContainerManager(new RuntimeConfig({ base: 'http://test.com/foo/' }));
await expect(manager.getContainer({ path: 'http://test.com/foo/' }))
.rejects.toThrow('Root does not have a container.');
await expect(manager.getContainer({ path: 'http://test.com/foo' }))
.rejects.toThrow('Root does not have a container.');
manager = new UrlContainerManager('http://test.com/foo');
manager = new UrlContainerManager(new RuntimeConfig({ base: 'http://test.com/foo' }));
await expect(manager.getContainer({ path: 'http://test.com/foo/' }))
.rejects.toThrow('Root does not have a container.');
await expect(manager.getContainer({ path: 'http://test.com/foo' }))
@@ -24,7 +25,7 @@ describe('An UrlContainerManager', (): void => {
});
it('errors when the root of an URl is reached that does not match the input root.', async(): Promise<void> => {
const manager = new UrlContainerManager('http://test.com/foo/');
const manager = new UrlContainerManager(new RuntimeConfig({ base: 'http://test.com/foo/' }));
await expect(manager.getContainer({ path: 'http://test.com/' }))
.rejects.toThrow('URL root reached.');
});