feat: Combine pod creation with IDP registration

This commit is contained in:
Joachim Van Herwegen
2021-05-28 16:38:35 +02:00
parent 9bb42ddf0d
commit 4d7d939dc4
18 changed files with 700 additions and 255 deletions

View File

@@ -1,6 +1,5 @@
import type { ResourceIdentifier } from '../../../src/ldp/representation/ResourceIdentifier';
import { ConfigPodManager } from '../../../src/pods/ConfigPodManager';
import type { IdentifierGenerator } from '../../../src/pods/generate/IdentifierGenerator';
import type { PodGenerator } from '../../../src/pods/generate/PodGenerator';
import type { Resource, ResourcesGenerator } from '../../../src/pods/generate/ResourcesGenerator';
import type { PodSettings } from '../../../src/pods/settings/PodSettings';
@@ -10,9 +9,6 @@ import type { ResourceStore } from '../../../src/storage/ResourceStore';
describe('A ConfigPodManager', (): void => {
let settings: PodSettings;
const base = 'http://test.com/';
const idGenerator: IdentifierGenerator = {
generate: (slug: string): ResourceIdentifier => ({ path: `${base}${slug}/` }),
};
let store: ResourceStore;
let podGenerator: PodGenerator;
let routingStorage: KeyValueStorage<string, ResourceStore>;
@@ -50,12 +46,12 @@ describe('A ConfigPodManager', (): void => {
set: async(key: ResourceIdentifier, value: ResourceStore): Promise<any> => map.set(key, value),
} as any;
manager = new ConfigPodManager(idGenerator, podGenerator, resourcesGenerator, routingStorage);
manager = new ConfigPodManager(podGenerator, resourcesGenerator, routingStorage);
});
it('creates a pod and returns the newly generated identifier.', async(): Promise<void> => {
const identifier = { path: `${base}alice/` };
await expect(manager.createPod(settings)).resolves.toEqual(identifier);
await expect(manager.createPod(identifier, settings)).resolves.toBeUndefined();
expect(podGenerator.generate).toHaveBeenCalledTimes(1);
expect(podGenerator.generate).toHaveBeenLastCalledWith(identifier, settings);
expect(resourcesGenerator.generate).toHaveBeenCalledTimes(1);