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
@@ -135,13 +135,7 @@ describe('AwsS3UrlReader', () => {
'getObject',
Buffer.from(
require('fs').readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'awsS3',
'awsS3-mock-object.yaml',
),
path.resolve(__dirname, '__fixtures__/awsS3/awsS3-mock-object.yaml'),
),
),
);
@@ -187,13 +181,7 @@ describe('AwsS3UrlReader', () => {
'getObject',
Buffer.from(
require('fs').readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'awsS3',
'awsS3-mock-object.yaml',
),
path.resolve(__dirname, '__fixtures__/awsS3/awsS3-mock-object.yaml'),
),
),
);
@@ -249,13 +237,7 @@ describe('AwsS3UrlReader', () => {
'getObject',
Buffer.from(
require('fs').readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'awsS3',
'awsS3-mock-object.yaml',
),
path.resolve(__dirname, '__fixtures__/awsS3/awsS3-mock-object.yaml'),
),
),
);
@@ -152,7 +152,7 @@ describe('AzureUrlReader', () => {
describe('readTree', () => {
const repoBuffer = fs.readFileSync(
path.resolve('src', 'reading', '__fixtures__', 'mock-main.zip'),
path.resolve(__dirname, '__fixtures__/mock-main.zip'),
);
const processor = new AzureUrlReader(
@@ -264,7 +264,7 @@ describe('AzureUrlReader', () => {
describe('search', () => {
const repoBuffer = fs.readFileSync(
path.resolve('src', 'reading', '__fixtures__', 'mock-main.zip'),
path.resolve(__dirname, '__fixtures__/mock-main.zip'),
);
const processor = new AzureUrlReader(
@@ -104,20 +104,13 @@ describe('BitbucketUrlReader', () => {
describe('readTree', () => {
const repoBuffer = fs.readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'bitbucket-repo-with-commit-hash.tar.gz',
__dirname,
'__fixtures__/bitbucket-repo-with-commit-hash.tar.gz',
),
);
const privateBitbucketRepoBuffer = fs.readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'bitbucket-server-repo.tar.gz',
),
path.resolve(__dirname, '__fixtures__/bitbucket-server-repo.tar.gz'),
);
beforeEach(() => {
@@ -298,10 +291,8 @@ describe('BitbucketUrlReader', () => {
describe('search hosted', () => {
const repoBuffer = fs.readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'bitbucket-repo-with-commit-hash.tar.gz',
__dirname,
'__fixtures__/bitbucket-repo-with-commit-hash.tar.gz',
),
);
@@ -386,12 +377,7 @@ describe('BitbucketUrlReader', () => {
describe('search private', () => {
const privateBitbucketRepoBuffer = fs.readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'bitbucket-server-repo.tar.gz',
),
path.resolve(__dirname, '__fixtures__/bitbucket-server-repo.tar.gz'),
);
beforeEach(() => {
@@ -254,12 +254,7 @@ describe('GithubUrlReader', () => {
describe('readTree', () => {
const repoBuffer = fs.readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'backstage-mock-etag123.tar.gz',
),
path.resolve(__dirname, '__fixtures__/backstage-mock-etag123.tar.gz'),
);
const reposGithubApiResponse = {
@@ -540,12 +535,7 @@ describe('GithubUrlReader', () => {
describe('search', () => {
const repoBuffer = fs.readFileSync(
path.resolve(
'src',
'reading',
'__fixtures__',
'backstage-mock-etag123.tar.gz',
),
path.resolve(__dirname, '__fixtures__/backstage-mock-etag123.tar.gz'),
);
const githubTreeContents: GhTreeResponse['tree'] = [
@@ -223,7 +223,7 @@ describe('GitlabUrlReader', () => {
describe('readTree', () => {
const archiveBuffer = fs.readFileSync(
path.resolve('src', 'reading', '__fixtures__', 'gitlab-archive.tar.gz'),
path.resolve(__dirname, '__fixtures__/gitlab-archive.tar.gz'),
);
const projectGitlabApiResponse = {
@@ -495,7 +495,7 @@ describe('GitlabUrlReader', () => {
describe('search', () => {
const archiveBuffer = fs.readFileSync(
path.resolve('src', 'reading', '__fixtures__', 'gitlab-archive.tar.gz'),
path.resolve(__dirname, '__fixtures__/gitlab-archive.tar.gz'),
);
const projectGitlabApiResponse = {
+2
View File
@@ -46,6 +46,8 @@ describe('paths', () => {
const dir = resolvePath(__dirname, '..');
const root = resolvePath(__dirname, '../../..');
jest.spyOn(process, 'cwd').mockReturnValue(dir);
const paths = findPaths(__dirname);
expect(paths.ownDir).toBe(dir);
@@ -31,15 +31,17 @@ describe('readAzureIntegrationConfig', () => {
data: Partial<AzureIntegrationConfig>,
): Promise<Config> {
const fullSchema = await loadConfigSchema({
dependencies: [require('../../package.json').name],
dependencies: ['@backstage/integration'],
});
const serializedSchema = fullSchema.serialize() as {
schemas: { path: string }[];
schemas: { value: { properties?: { integrations?: object } } }[];
};
const schema = await loadConfigSchema({
serialized: {
...serializedSchema, // grab the schema from this package only
schemas: serializedSchema.schemas.filter(s => s.path === 'config.d.ts'),
...serializedSchema, // only include schemas that apply to integrations
schemas: serializedSchema.schemas.filter(
s => s.value?.properties?.integrations,
),
},
});
const processed = schema.process(
@@ -31,15 +31,17 @@ describe('readBitbucketIntegrationConfig', () => {
data: Partial<BitbucketIntegrationConfig>,
): Promise<Config> {
const fullSchema = await loadConfigSchema({
dependencies: [require('../../package.json').name],
dependencies: ['@backstage/integration'],
});
const serializedSchema = fullSchema.serialize() as {
schemas: { path: string }[];
schemas: { value: { properties?: { integrations?: object } } }[];
};
const schema = await loadConfigSchema({
serialized: {
...serializedSchema, // grab the schema from this package only
schemas: serializedSchema.schemas.filter(s => s.path === 'config.d.ts'),
...serializedSchema, // only include schemas that apply to integrations
schemas: serializedSchema.schemas.filter(
s => s.value?.properties?.integrations,
),
},
});
const processed = schema.process(
@@ -31,15 +31,17 @@ describe('readGitHubIntegrationConfig', () => {
data: Partial<GitHubIntegrationConfig>,
): Promise<Config> {
const fullSchema = await loadConfigSchema({
dependencies: [require('../../package.json').name],
dependencies: ['@backstage/integration'],
});
const serializedSchema = fullSchema.serialize() as {
schemas: { path: string }[];
schemas: { value: { properties?: { integrations?: object } } }[];
};
const schema = await loadConfigSchema({
serialized: {
...serializedSchema, // grab the schema from this package only
schemas: serializedSchema.schemas.filter(s => s.path === 'config.d.ts'),
...serializedSchema, // only include schemas that apply to integrations
schemas: serializedSchema.schemas.filter(
s => s.value?.properties?.integrations,
),
},
});
const processed = schema.process(
@@ -31,15 +31,17 @@ describe('readGitLabIntegrationConfig', () => {
data: Partial<GitLabIntegrationConfig>,
): Promise<Config> {
const fullSchema = await loadConfigSchema({
dependencies: [require('../../package.json').name],
dependencies: ['@backstage/integration'],
});
const serializedSchema = fullSchema.serialize() as {
schemas: { path: string }[];
schemas: { value: { properties?: { integrations?: object } } }[];
};
const schema = await loadConfigSchema({
serialized: {
...serializedSchema, // grab the schema from this package only
schemas: serializedSchema.schemas.filter(s => s.path === 'config.d.ts'),
...serializedSchema, // only include schemas that apply to integrations
schemas: serializedSchema.schemas.filter(
s => s.value?.properties?.integrations,
),
},
});
const processed = schema.process(