Skip to content

Commit

Permalink
fix merging issues
Browse files Browse the repository at this point in the history
  • Loading branch information
maartyman committed Feb 8, 2024
1 parent a1589a7 commit 12da888
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
4 changes: 2 additions & 2 deletions lib/pod/IPod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ServiceDescription } from '../service/IService';
import type { IServiceDescription } from '../service/IService';

export interface IPod {
newServiceLocation: (description: ServiceDescription) => Promise<string>;
newServiceLocation: (description: IServiceDescription) => Promise<string>;
}

export type PodServiceLocation = string;
4 changes: 2 additions & 2 deletions lib/pod/PodCss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from 'fs-extra';
import { AppRunner } from '@solid/community-server';
import { v4 } from 'uuid';
import { AsyncConstructor } from '../core/AsyncConstructor';
import type { ServiceDescription } from '../service/IService';
import type { IServiceDescription } from '../service/IService';
import type { IPod, PodServiceLocation } from './IPod';

export class PodCss extends AsyncConstructor implements IPod {
Expand Down Expand Up @@ -39,7 +39,7 @@ export class PodCss extends AsyncConstructor implements IPod {
// TODO [2024-03-01]: Edit profile card
}

public async newServiceLocation(description: ServiceDescription): Promise<PodServiceLocation> {
public async newServiceLocation(description: IServiceDescription): Promise<PodServiceLocation> {
if (!this.initialized) {
await new Promise<void>((resolve): void => {
this.subscribeInitialized((): void => {
Expand Down
26 changes: 23 additions & 3 deletions lib/service-registry/test/ServiceRegistryHardcodedTestOnly-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,28 @@ describe('ServiceRegistryHardcodedTestOnly', (): void => {

beforeEach((): void => {
mockAggregatorServices = [
({ initialize: jest.fn(), test: jest.fn(), description: 'Service1' } as any) as IService,
({ initialize: jest.fn(), test: jest.fn(), description: 'Service2' } as any) as IService,
({
subscribeInitialized: jest.fn(
(resolve): void => {
resolve();
},
),
test: jest.fn(),
description: {
toString: (): string => 'Service1',
},
} as any) as IService,
({
subscribeInitialized: jest.fn(
(resolve): void => {
resolve();
},
),
test: jest.fn(),
description: {
toString: (): string => 'Service2',
},
} as any) as IService,
];

mockCostQueueFactory = {
Expand All @@ -24,7 +44,7 @@ describe('ServiceRegistryHardcodedTestOnly', (): void => {
it('should initialize all services.', async(): Promise<void> => {
await serviceRegistry.initializeServices();
for (const service of mockAggregatorServices) {
expect(service.initialize).toHaveBeenCalledWith();
expect(service.subscribeInitialized).toHaveBeenCalledWith(expect.any(Function));
}
});
});
Expand Down
8 changes: 4 additions & 4 deletions lib/service/ServiceAggregation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { v4 } from 'uuid';
import type { IFetch } from '../fetch/IFetch';
import type { IPod } from '../pod/IPod';
import { AsyncConstructor } from '../core/AsyncConstructor';
import type { IService, Operation, OperationResult, OperationTestResult, ServiceDescription } from './IService';
import type { IOperation, IOperationResult, IOperationTestResult, IService, IServiceDescription } from './IService';

export class ServiceAggregation extends AsyncConstructor implements IService {
public fetch: IFetch;
Expand All @@ -20,7 +20,7 @@ export class ServiceAggregation extends AsyncConstructor implements IService {
this.podLocation = await args.pod.newServiceLocation(this.description);
}

public async test(operation: Operation): Promise<OperationTestResult> {
public async test(operation: IOperation): Promise<IOperationTestResult> {
if (operation.operation !== 'Aggregation') {
throw new Error('Not an aggregation operation');
}
Expand All @@ -31,7 +31,7 @@ export class ServiceAggregation extends AsyncConstructor implements IService {
};
}

public async run(operation: Operation): Promise<OperationResult> {
public async run(operation: IOperation): Promise<IOperationResult> {
const resultLocation = `${this.podLocation}/${v4()}.ttl`;

const streamWriter = new StreamWriter();
Expand All @@ -57,7 +57,7 @@ export class ServiceAggregation extends AsyncConstructor implements IService {
};
}

public get description(): ServiceDescription {
public get description(): IServiceDescription {
return {
toString: (): string => 'Aggregation',
};
Expand Down
13 changes: 6 additions & 7 deletions lib/service/ServiceEmpty.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import { AsyncConstructor } from '../core/AsyncConstructor';
import type { IPod } from '../pod/IPod';
import type { IFetch } from '../fetch/IFetch';
import type { IService, Operation, OperationResult, OperationTestResult, ServiceDescription } from './IService';
import type { ServiceAggregationArgs } from './ServiceAggregation';
import type { IOperation, IOperationResult, IOperationTestResult, IService, IServiceDescription } from './IService';

export class ServiceEmpty extends AsyncConstructor implements IService {
private podLocation: string | undefined;
public fetch: IFetch;
public pod: IPod;

public constructor(args: ServiceAggregationArgs) {
public constructor(args: ServiceEmptyArgs) {
super(args);
this.fetch = args.fetch;
this.pod = args.pod;
}

protected async initialize(args: ServiceAggregationArgs): Promise<void> {
protected async initialize(args: ServiceEmptyArgs): Promise<void> {
this.podLocation = await args.pod.newServiceLocation(this.description);
}

public async test(operation: Operation): Promise<OperationTestResult> {
public async test(operation: IOperation): Promise<IOperationTestResult> {
if (operation.operation !== 'Empty') {
throw new Error('Not a Empty operation');
}
Expand All @@ -30,15 +29,15 @@ export class ServiceEmpty extends AsyncConstructor implements IService {
};
}

public async run(operation: Operation): Promise<OperationResult> {
public async run(operation: IOperation): Promise<IOperationResult> {
return {
aggregatorService: this,
operation,
resultLocation: '',
};
}

public get description(): ServiceDescription {
public get description(): IServiceDescription {
return {
toString: (): string => 'Empty',
};
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 12da888

Please sign in to comment.