Skip to content

Commit

Permalink
Revert "undo trailing commas to test code cov"
Browse files Browse the repository at this point in the history
This reverts commit e5bf319.
  • Loading branch information
lindot11 committed Nov 25, 2023
1 parent e5bf319 commit cbd6eb3
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 100 deletions.
10 changes: 5 additions & 5 deletions servers/lib/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import FilesModule from './files/files.module';
@Module({
imports: [
ConfigModule.forRoot({
isGlobal: true
isGlobal: true,
}),
GraphQLModule.forRootAsync({
driver: ApolloDriver,
useFactory: (configService: ConfigService) => ({
autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
path: configService.get<string>('APOLLO_PATH')
path: configService.get<string>('APOLLO_PATH'),
}),
inject: [ConfigService]
inject: [ConfigService],
}),
FilesModule
]
FilesModule,
],
})
export default class AppModule {}
2 changes: 1 addition & 1 deletion servers/lib/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type BootstrapOptions = {
export default async function bootstrap(options?: BootstrapOptions) {
const configFile = dotenv.config({
path: options?.config ?? '.env',
override: true
override: true,
});
if (configFile.error) {
// eslint-disable-next-line no-console
Expand Down
4 changes: 2 additions & 2 deletions servers/lib/src/files/files.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import LocalFilesService from './services/local-files.service';
FilesResolver,
LocalFilesService,
GitlabFilesService,
FilesServiceFactory
]
FilesServiceFactory,
],
})
export default class FilesModule {}
2 changes: 1 addition & 1 deletion servers/lib/src/files/services/files-service.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class FilesServiceFactory {
constructor(
private configService: ConfigService,
@Inject(GitlabFilesService) private gitlabFilesService: GitlabFilesService,
@Inject(LocalFilesService) private localFilesService: LocalFilesService
@Inject(LocalFilesService) private localFilesService: LocalFilesService,
) {}
/* eslint-enable no-useless-constructor, no-empty-function */

Expand Down
10 changes: 5 additions & 5 deletions servers/lib/src/files/services/gitlab-files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class GitlabFilesService implements IFilesService {
}

private async parseArguments(
path: string
path: string,
): Promise<{ domain: string; parsedPath: string }> {
const gitlabGroup = this.configService.get('GITLAB_GROUP');
const pathParts: string[] = path.split('/');
Expand All @@ -42,11 +42,11 @@ export default class GitlabFilesService implements IFilesService {
method: 'post',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.configService.get('GITLAB_TOKEN')}`
Authorization: `Bearer ${this.configService.get('GITLAB_TOKEN')}`,
},
data: {
query
}
query,
},
});
return response.data.data.project;
} catch (error) {
Expand All @@ -56,7 +56,7 @@ export default class GitlabFilesService implements IFilesService {

private async executeQuery(
path: string,
getQuery: QueryFunction
getQuery: QueryFunction,
): Promise<Project> {
const { domain, parsedPath } = await this.parseArguments(path);
const query = getQuery(domain, parsedPath);
Expand Down
18 changes: 9 additions & 9 deletions servers/lib/src/files/services/local-files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ export default class LocalFilesService implements IFilesService {
const files = await fs.promises.readdir(fullPath);

const edges = await Promise.all(
files.map((file) => LocalFilesService.getFileStats(fullPath, file))
files.map((file) => LocalFilesService.getFileStats(fullPath, file)),
);

const tree = {
trees: {
edges: edges.filter((edge) => edge.node.type === 'tree')
edges: edges.filter((edge) => edge.node.type === 'tree'),
},
blobs: {
edges: edges.filter((edge) => edge.node.type === 'blob')
}
edges: edges.filter((edge) => edge.node.type === 'blob'),
},
};

return { repository: { tree } };
Expand Down Expand Up @@ -66,11 +66,11 @@ export default class LocalFilesService implements IFilesService {
{
name,
rawBlob: content,
rawTextBlob: content
}
]
}
}
rawTextBlob: content,
},
],
},
},
};
}
}
2 changes: 1 addition & 1 deletion servers/lib/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const program = new Command();

program
.description(
'The lib microservice is responsible for handling and serving the contents of library assets of the DTaaS platform. It provides API endpoints for clients to query, and fetch these assets.'
'The lib microservice is responsible for handling and serving the contents of library assets of the DTaaS platform. It provides API endpoints for clients to query, and fetch these assets.',
)
.option('-c, --config <path>', 'set the config path (default .env)')
.helpOption('-h, --help', 'display help for libms')
Expand Down
4 changes: 2 additions & 2 deletions servers/lib/test/e2e/app.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
e2eReadFile,
e2elistDirectory,
expectedFileContentResponse,
expectedListDirectoryResponse
expectedListDirectoryResponse,
} from '../testUtil';

describe('End to End test for the application', () => {
Expand All @@ -17,7 +17,7 @@ describe('End to End test for the application', () => {
// execSync("test/starttraefik.bash");

const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule]
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
await app.init(); // Initialize the application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
pathToTestFileContent,
testDirectory,
testFileContent,
MockConfigService
MockConfigService,
} from '../testUtil';

describe('Integration tests for FilesResolver', () => {
Expand All @@ -24,8 +24,8 @@ describe('Integration tests for FilesResolver', () => {
FilesServiceFactory,
LocalFilesService,
GitlabFilesService,
{ provide: ConfigService, useClass: MockConfigService }
]
{ provide: ConfigService, useClass: MockConfigService },
],
}).compile();

filesResolver = module.get<FilesResolver>(FilesResolver);
Expand Down
82 changes: 41 additions & 41 deletions servers/lib/test/testUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export const testDirectory = {
{ node: { name: 'digital_twins', type: 'tree' } },
{ node: { name: 'functions', type: 'tree' } },
{ node: { name: 'models', type: 'tree' } },
{ node: { name: 'tools', type: 'tree' } }
]
}
}
}
{ node: { name: 'tools', type: 'tree' } },
],
},
},
},
};
export const testFileName = 'README.md';
export const fstestFileContent = 'content123';
Expand All @@ -32,7 +32,7 @@ export const testFileArray = [
'digital_twins',
'functions',
'models',
'tools'
'tools',
];
export const testFileContent = {
repository: {
Expand All @@ -41,11 +41,11 @@ export const testFileContent = {
{
name: 'README.md',
rawBlob: 'content123',
rawTextBlob: 'content123'
}
]
}
}
rawTextBlob: 'content123',
},
],
},
},
};

export function sleep(ms) {
Expand Down Expand Up @@ -91,12 +91,12 @@ export const mockReadFileResponseData = {
__typename: 'Blob',
name: 'README.md',
rawBlob: 'content123',
rawTextBlob: 'content123'
}
]
}
}
}
rawTextBlob: 'content123',
},
],
},
},
},
};

export const expectedListDirectoryResponse = {
Expand All @@ -108,35 +108,35 @@ export const expectedListDirectoryResponse = {
edges: [
{
node: {
name: 'data'
}
name: 'data',
},
},
{
node: {
name: 'digital_twins'
}
name: 'digital_twins',
},
},
{
node: {
name: 'functions'
}
name: 'functions',
},
},
{
node: {
name: 'models'
}
name: 'models',
},
},
{
node: {
name: 'tools'
}
}
]
}
}
}
}
}
name: 'tools',
},
},
],
},
},
},
},
},
};

export const expectedFileContentResponse = {
Expand All @@ -148,13 +148,13 @@ export const expectedFileContentResponse = {
{
name: 'README.md',
rawBlob: 'content123',
rawTextBlob: 'content123'
}
]
}
}
}
}
rawTextBlob: 'content123',
},
],
},
},
},
},
};

export const e2elistDirectory = `query {
Expand Down
4 changes: 2 additions & 2 deletions servers/lib/test/unit/files-service.factory.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe('FilesServiceFactory', () => {
FilesServiceFactory,
{ provide: ConfigService, useValue: { get: jest.fn() } },
{ provide: LocalFilesService, useValue: localFilesService },
{ provide: GitlabFilesService, useValue: gitlabFilesService }
]
{ provide: GitlabFilesService, useValue: gitlabFilesService },
],
}).compile();

serviceFactory = module.get<FilesServiceFactory>(FilesServiceFactory);
Expand Down
14 changes: 7 additions & 7 deletions servers/lib/test/unit/files.resolver.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
testDirectory,
pathToTestDirectory,
pathToTestFileContent,
testFileContent
testFileContent,
} from '../testUtil';
import { IFilesService } from '../../src/files/interfaces/files.service.interface';
import FilesServiceFactory from '../../src/files/services/files-service.factory';
Expand All @@ -16,7 +16,7 @@ describe('Unit tests for FilesResolver', () => {
beforeEach(async () => {
const mockFilesService: IFilesService = {
listDirectory: jest.fn().mockImplementation(() => testDirectory),
readFile: jest.fn().mockImplementation(() => testFileContent)
readFile: jest.fn().mockImplementation(() => testFileContent),
};

const module: TestingModule = await Test.createTestingModule({
Expand All @@ -26,10 +26,10 @@ describe('Unit tests for FilesResolver', () => {
{
provide: FilesServiceFactory,
useValue: {
create: () => mockFilesService
}
}
]
create: () => mockFilesService,
},
},
],
}).compile();

filesResolver = module.get<FilesResolver>(FilesResolver);
Expand All @@ -51,7 +51,7 @@ describe('Unit tests for FilesResolver', () => {
const result = await filesResolver.listDirectory(pathToTestDirectory);
expect(result).toEqual(testDirectory);
expect(filesService.listDirectory).toHaveBeenCalledWith(
pathToTestDirectory
pathToTestDirectory,
);
});
});
Expand Down
6 changes: 3 additions & 3 deletions servers/lib/test/unit/gitlab-files.service.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
pathToTestFileContent,
testFileContent,
MockConfigService,
testDirectory
testDirectory,
} from '../testUtil';

describe('GitlabFilesService', () => {
Expand All @@ -18,8 +18,8 @@ describe('GitlabFilesService', () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
GitlabFilesService,
{ provide: ConfigService, useValue: mockConfigService }
]
{ provide: ConfigService, useValue: mockConfigService },
],
})
.overrideProvider(ConfigService)
.useValue(mockConfigService)
Expand Down
Loading

0 comments on commit cbd6eb3

Please sign in to comment.