refactor: stop using getVoidLogger in tests
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
@@ -14,12 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { ContainerRunner, getVoidLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
ContainerRunner,
|
||||
loggerToWinstonLogger,
|
||||
} from '@backstage/backend-common';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { Generators } from './generators';
|
||||
import { TechdocsGenerator } from './techdocs';
|
||||
import { mockServices } from '@backstage/backend-test-utils';
|
||||
|
||||
const logger = getVoidLogger();
|
||||
const logger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
|
||||
const mockEntity = {
|
||||
apiVersion: 'version',
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
import { createMockDirectory } from '@backstage/backend-test-utils';
|
||||
import {
|
||||
createMockDirectory,
|
||||
mockServices,
|
||||
} from '@backstage/backend-test-utils';
|
||||
import fs from 'fs-extra';
|
||||
import path, { resolve as resolvePath } from 'path';
|
||||
import { ParsedLocationAnnotation } from '../../helpers';
|
||||
@@ -35,6 +37,7 @@ import {
|
||||
patchMkdocsYmlWithPlugins,
|
||||
} from './mkdocsPatchers';
|
||||
import yaml from 'js-yaml';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
|
||||
const mockEntity = {
|
||||
apiVersion: 'version',
|
||||
@@ -90,7 +93,7 @@ const mkdocsYmlWithAdditionalPluginsWithConfig = fs.readFileSync(
|
||||
const mkdocsYmlWithEnvTag = fs.readFileSync(
|
||||
resolvePath(__filename, '../__fixtures__/mkdocs_with_env_tag.yml'),
|
||||
);
|
||||
const mockLogger = getVoidLogger();
|
||||
const mockLogger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
const warn = jest.spyOn(mockLogger, 'warn');
|
||||
|
||||
const scmIntegrations = ScmIntegrations.fromConfig(new ConfigReader({}));
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { getVoidLogger, UrlReader } from '@backstage/backend-common';
|
||||
import { UrlReader, loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { DirectoryPreparer } from './dir';
|
||||
import { mockServices } from '@backstage/backend-test-utils';
|
||||
|
||||
function normalizePath(path: string) {
|
||||
return path
|
||||
@@ -28,7 +29,7 @@ jest.mock('../../helpers', () => ({
|
||||
...jest.requireActual<{}>('../../helpers'),
|
||||
}));
|
||||
|
||||
const logger = getVoidLogger();
|
||||
const logger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
|
||||
const createMockEntity = (annotations: {}) => {
|
||||
return {
|
||||
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
S3Client,
|
||||
UploadPartCommand,
|
||||
} from '@aws-sdk/client-s3';
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { Entity, DEFAULT_NAMESPACE } from '@backstage/catalog-model';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import {
|
||||
@@ -39,7 +38,11 @@ import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import { AwsS3Publish } from './awsS3';
|
||||
import { Readable } from 'stream';
|
||||
import { createMockDirectory } from '@backstage/backend-test-utils';
|
||||
import {
|
||||
createMockDirectory,
|
||||
mockServices,
|
||||
} from '@backstage/backend-test-utils';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
|
||||
const env = process.env;
|
||||
let s3Mock: AwsClientStub<S3Client>;
|
||||
@@ -87,7 +90,7 @@ class ErrorReadable extends Readable {
|
||||
}
|
||||
}
|
||||
|
||||
const logger = getVoidLogger();
|
||||
const logger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
const loggerInfoSpy = jest.spyOn(logger, 'info');
|
||||
const loggerErrorSpy = jest.spyOn(logger, 'error');
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import { Entity, DEFAULT_NAMESPACE } from '@backstage/catalog-model';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import express from 'express';
|
||||
@@ -27,7 +27,10 @@ import {
|
||||
BlobUploadCommonResponse,
|
||||
ContainerGetPropertiesResponse,
|
||||
} from '@azure/storage-blob';
|
||||
import { createMockDirectory } from '@backstage/backend-test-utils';
|
||||
import {
|
||||
createMockDirectory,
|
||||
mockServices,
|
||||
} from '@backstage/backend-test-utils';
|
||||
|
||||
const mockDir = createMockDirectory();
|
||||
|
||||
@@ -221,7 +224,7 @@ const getEntityRootDir = (entity: Entity) => {
|
||||
return mockDir.resolve(namespace || DEFAULT_NAMESPACE, kind, name);
|
||||
};
|
||||
|
||||
const logger = getVoidLogger();
|
||||
const logger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
jest.spyOn(logger, 'error').mockReturnValue(logger);
|
||||
|
||||
const createPublisherFromConfig = ({
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import { Entity, DEFAULT_NAMESPACE } from '@backstage/catalog-model';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import express from 'express';
|
||||
@@ -23,7 +23,10 @@ import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import { Readable } from 'stream';
|
||||
import { GoogleGCSPublish } from './googleStorage';
|
||||
import { createMockDirectory } from '@backstage/backend-test-utils';
|
||||
import {
|
||||
createMockDirectory,
|
||||
mockServices,
|
||||
} from '@backstage/backend-test-utils';
|
||||
|
||||
const mockDir = createMockDirectory();
|
||||
|
||||
@@ -136,7 +139,7 @@ const getEntityRootDir = (entity: Entity) => {
|
||||
return mockDir.resolve(namespace || DEFAULT_NAMESPACE, kind, name);
|
||||
};
|
||||
|
||||
const logger = getVoidLogger();
|
||||
const logger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
jest.spyOn(logger, 'info').mockReturnValue(logger);
|
||||
jest.spyOn(logger, 'error').mockReturnValue(logger);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
getVoidLogger,
|
||||
loggerToWinstonLogger,
|
||||
PluginEndpointDiscovery,
|
||||
} from '@backstage/backend-common';
|
||||
import { overridePackagePathResolution } from '@backstage/backend-plugin-api/testUtils';
|
||||
@@ -24,7 +24,10 @@ import request from 'supertest';
|
||||
import * as os from 'os';
|
||||
import { LocalPublish } from './local';
|
||||
import path from 'path';
|
||||
import { createMockDirectory } from '@backstage/backend-test-utils';
|
||||
import {
|
||||
createMockDirectory,
|
||||
mockServices,
|
||||
} from '@backstage/backend-test-utils';
|
||||
|
||||
const createMockEntity = (annotations = {}, lowerCase = false) => {
|
||||
return {
|
||||
@@ -53,7 +56,7 @@ overridePackagePathResolution({
|
||||
},
|
||||
});
|
||||
|
||||
const logger = getVoidLogger();
|
||||
const logger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
|
||||
describe('local publisher', () => {
|
||||
const mockDir = createMockDirectory();
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getVoidLogger } from '@backstage/backend-common';
|
||||
import { loggerToWinstonLogger } from '@backstage/backend-common';
|
||||
import {
|
||||
Entity,
|
||||
CompoundEntityRef,
|
||||
@@ -28,7 +28,10 @@ import path from 'path';
|
||||
import { OpenStackSwiftPublish } from './openStackSwift';
|
||||
import { PublisherBase, TechDocsMetadata } from './types';
|
||||
import { Stream, Readable } from 'stream';
|
||||
import { createMockDirectory } from '@backstage/backend-test-utils';
|
||||
import {
|
||||
createMockDirectory,
|
||||
mockServices,
|
||||
} from '@backstage/backend-test-utils';
|
||||
|
||||
const mockDir = createMockDirectory();
|
||||
|
||||
@@ -169,7 +172,7 @@ const getPosixEntityRootDir = (entity: Entity) => {
|
||||
);
|
||||
};
|
||||
|
||||
const logger = getVoidLogger();
|
||||
const logger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
|
||||
let publisher: PublisherBase;
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
getVoidLogger,
|
||||
PluginEndpointDiscovery,
|
||||
loggerToWinstonLogger,
|
||||
} from '@backstage/backend-common';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { Publisher } from './publish';
|
||||
@@ -24,8 +24,9 @@ import { GoogleGCSPublish } from './googleStorage';
|
||||
import { AwsS3Publish } from './awsS3';
|
||||
import { AzureBlobStoragePublish } from './azureBlobStorage';
|
||||
import { OpenStackSwiftPublish } from './openStackSwift';
|
||||
import { mockServices } from '@backstage/backend-test-utils';
|
||||
|
||||
const logger = getVoidLogger();
|
||||
const logger = loggerToWinstonLogger(mockServices.logger.mock());
|
||||
const discovery: jest.Mocked<PluginEndpointDiscovery> = {
|
||||
getBaseUrl: jest.fn().mockResolvedValueOnce('http://localhost:7007'),
|
||||
getExternalBaseUrl: jest.fn(),
|
||||
|
||||
Reference in New Issue
Block a user