removed mock-fs in scaffolder rails

Signed-off-by: Ankit Anand <ankitanand.l@flipkart.com>
This commit is contained in:
Ankit Anand
2023-10-19 04:43:24 +05:30
parent 4996c0d0c3
commit 47dc8b84b3
3 changed files with 12 additions and 13 deletions
@@ -39,13 +39,12 @@
"fs-extra": "^10.0.1"
},
"devDependencies": {
"@backstage/backend-test-utils": "workspace:^",
"@backstage/cli": "workspace:^",
"@types/command-exists": "^1.2.0",
"@types/fs-extra": "^9.0.1",
"@types/mock-fs": "^4.13.0",
"@types/node": "^18.17.8",
"jest-when": "^3.1.0",
"mock-fs": "^5.2.0"
"jest-when": "^3.1.0"
},
"files": [
"dist"
@@ -34,14 +34,14 @@ import {
} from '@backstage/backend-common';
import { ConfigReader } from '@backstage/config';
import { ScmIntegrations } from '@backstage/integration';
import mockFs from 'mock-fs';
import os from 'os';
import { resolve as resolvePath } from 'path';
import { PassThrough } from 'stream';
import { createFetchRailsAction } from './index';
import { fetchContents } from '@backstage/plugin-scaffolder-node';
import { createMockDirectory } from '@backstage/backend-test-utils';
describe('fetch:rails', () => {
const mockDir = createMockDirectory();
const integrations = ScmIntegrations.fromConfig(
new ConfigReader({
integrations: {
@@ -53,7 +53,7 @@ describe('fetch:rails', () => {
}),
);
const mockTmpDir = os.tmpdir();
const mockTmpDir = mockDir.path;
const mockContext = {
input: {
url: 'https://rubyonrails.org/generator',
@@ -73,6 +73,9 @@ describe('fetch:rails', () => {
createTemporaryDirectory: jest.fn().mockResolvedValue(mockTmpDir),
};
mockDir.clear();
mockDir.addContent({ template: {} });
const mockReader: UrlReader = {
readUrl: jest.fn(),
readTree: jest.fn(),
@@ -90,14 +93,12 @@ describe('fetch:rails', () => {
});
beforeEach(() => {
mockFs({ [`${mockContext.workspacePath}/result`]: {} });
mockDir.addContent({
result: '{}',
});
jest.clearAllMocks();
});
afterEach(() => {
mockFs.restore();
});
it('should call fetchContents with the correct values', async () => {
await action.handler(mockContext);
+1 -2
View File
@@ -8494,6 +8494,7 @@ __metadata:
resolution: "@backstage/plugin-scaffolder-backend-module-rails@workspace:plugins/scaffolder-backend-module-rails"
dependencies:
"@backstage/backend-common": "workspace:^"
"@backstage/backend-test-utils": "workspace:^"
"@backstage/cli": "workspace:^"
"@backstage/config": "workspace:^"
"@backstage/errors": "workspace:^"
@@ -8502,12 +8503,10 @@ __metadata:
"@backstage/types": "workspace:^"
"@types/command-exists": ^1.2.0
"@types/fs-extra": ^9.0.1
"@types/mock-fs": ^4.13.0
"@types/node": ^18.17.8
command-exists: ^1.2.9
fs-extra: ^10.0.1
jest-when: ^3.1.0
mock-fs: ^5.2.0
languageName: unknown
linkType: soft