plugins,packages: replace usages of ConfigReader.from

This commit is contained in:
Patrik Oldsberg
2020-12-15 19:04:50 +01:00
parent a3b2c5a68b
commit 1da7d2c657
34 changed files with 174 additions and 322 deletions
@@ -39,10 +39,7 @@ describe('generators', () => {
it('should return correct registered generator', async () => {
const generators = new Generators();
const techdocs = new TechdocsGenerator(
logger,
ConfigReader.fromConfigs([]),
);
const techdocs = new TechdocsGenerator(logger, new ConfigReader({}));
generators.register('techdocs', techdocs);
@@ -38,24 +38,19 @@ jest.spyOn(logger, 'info').mockReturnValue(logger);
let publisher: PublisherBase;
beforeEach(() => {
const mockConfig = ConfigReader.fromConfigs([
{
context: '',
data: {
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'googleGcs',
googleGcs: {
credentials: '{}',
projectId: 'gcp-project-id',
bucketName: 'bucketName',
},
},
const mockConfig = new ConfigReader({
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'googleGcs',
googleGcs: {
credentials: '{}',
projectId: 'gcp-project-id',
bucketName: 'bucketName',
},
},
},
]);
});
publisher = GoogleGCSPublish.fromConfig(mockConfig, logger);
});
@@ -63,17 +63,12 @@ describe('local publisher', () => {
getExternalBaseUrl: jest.fn(),
};
const mockConfig = ConfigReader.fromConfigs([
{
context: '',
data: {
techdocs: {
requestUrl: 'http://localhost:7000',
storageUrl: 'http://localhost:7000/static/docs',
},
},
const mockConfig = new ConfigReader({
techdocs: {
requestUrl: 'http://localhost:7000',
storageUrl: 'http://localhost:7000/static/docs',
},
]);
});
const publisher = new LocalPublish(mockConfig, logger, testDiscovery);
const mockEntity = createMockEntity();
@@ -30,59 +30,44 @@ const testDiscovery: jest.Mocked<PluginEndpointDiscovery> = {
describe('Publisher', () => {
it('should create local publisher by default', () => {
const mockConfig = ConfigReader.fromConfigs([
{
context: '',
data: {
techdocs: {
requestUrl: 'http://localhost:7000',
},
},
const mockConfig = new ConfigReader({
techdocs: {
requestUrl: 'http://localhost:7000',
},
]);
});
const publisher = Publisher.fromConfig(mockConfig, logger, testDiscovery);
expect(publisher).toBeInstanceOf(LocalPublish);
});
it('should create local publisher from config', () => {
const mockConfig = ConfigReader.fromConfigs([
{
context: '',
data: {
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'local',
},
},
const mockConfig = new ConfigReader({
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'local',
},
},
]);
});
const publisher = Publisher.fromConfig(mockConfig, logger, testDiscovery);
expect(publisher).toBeInstanceOf(LocalPublish);
});
it('should create google gcs publisher from config', () => {
const mockConfig = ConfigReader.fromConfigs([
{
context: '',
data: {
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'googleGcs',
googleGcs: {
credentials: '{}',
projectId: 'gcp-project-id',
bucketName: 'bucketName',
},
},
const mockConfig = new ConfigReader({
techdocs: {
requestUrl: 'http://localhost:7000',
publisher: {
type: 'googleGcs',
googleGcs: {
credentials: '{}',
projectId: 'gcp-project-id',
bucketName: 'bucketName',
},
},
},
]);
});
const publisher = Publisher.fromConfig(mockConfig, logger, testDiscovery);
expect(publisher).toBeInstanceOf(GoogleGCSPublish);