update tests to be runnable from the project root

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2021-10-09 13:52:20 +02:00
parent 16f044cb6b
commit f25b8459cd
14 changed files with 54 additions and 97 deletions
@@ -37,13 +37,8 @@ AWSMock.mock(
Buffer.from(
require('fs').readFileSync(
path.resolve(
'src',
'ingestion',
'processors',
'__fixtures__',
'fileReaderProcessor',
'awsS3',
'awsS3-mock-object.txt',
__dirname,
'__fixtures__/fileReaderProcessor/awsS3/awsS3-mock-object.txt',
),
),
),
@@ -23,13 +23,7 @@ import {
import path from 'path';
describe('FileReaderProcessor', () => {
const fixturesRoot = path.join(
'src',
'ingestion',
'processors',
'__fixtures__',
'fileReaderProcessor',
);
const fixturesRoot = path.join(__dirname, '__fixtures__/fileReaderProcessor');
it('should load from file', async () => {
const processor = new FileReaderProcessor();
@@ -14,7 +14,6 @@
* limitations under the License.
*/
import { resolvePackagePath } from '@backstage/backend-common';
import { ConfigReader } from '@backstage/config';
import path from 'path';
import { ConfigLocationEntityProvider } from './ConfigLocationEntityProvider';
@@ -44,10 +43,7 @@ describe('ConfigLocationEntityProvider', () => {
{
entity: expect.objectContaining({
spec: {
target: path.join(
resolvePackagePath('@backstage/plugin-catalog-backend'),
'./lols.yaml',
),
target: path.join(process.cwd(), 'lols.yaml'),
type: 'file',
},
}),
@@ -15,10 +15,14 @@
*/
import os from 'os';
import { join as joinPath, resolve as resolvePath } from 'path';
import { join as joinPath } from 'path';
import fs from 'fs-extra';
import mockFs from 'mock-fs';
import { getVoidLogger, UrlReader } from '@backstage/backend-common';
import {
getVoidLogger,
resolvePackagePath,
UrlReader,
} from '@backstage/backend-common';
import { ScmIntegrations } from '@backstage/integration';
import { PassThrough } from 'stream';
import { fetchContents } from './helpers';
@@ -30,9 +34,9 @@ jest.mock('./helpers', () => ({
}));
const aBinaryFile = fs.readFileSync(
resolvePath(
'src',
'../fixtures/test-nested-template/public/react-logo192.png',
resolvePackagePath(
'@backstage/plugin-scaffolder-backend',
'fixtures/test-nested-template/public/react-logo192.png',
),
);