Skip to content

Commit

Permalink
test(nx-python): mock checkPoetryExecutable in executor and generator…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
lucasvieirasilva committed Dec 13, 2024
1 parent eb853d4 commit 31e1096
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/nx-python/src/executors/sls-deploy/executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ describe('Serverless Framework Deploy Executor', () => {
.spyOn(poetryUtils, 'activateVenv')
.mockReturnValue(undefined);
vi.spyOn(process, 'chdir').mockReturnValue(undefined);

vi.spyOn(poetryUtils, 'checkPoetryExecutable').mockReturnValue(undefined);
});

it('should throw an exception when the dist folder is empty', async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/nx-python/src/executors/sls-package/executor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ describe('Serverless Framework Package Executor', () => {
.spyOn(poetryUtils, 'activateVenv')
.mockReturnValue(undefined);
vi.spyOn(process, 'chdir').mockReturnValue(undefined);

vi.spyOn(poetryUtils, 'checkPoetryExecutable').mockReturnValue(undefined);
});

it('should throw an exception when the dist folder is empty', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import generator from './generator';
import projectGenerator from '../poetry-project/generator';
import spawn from 'cross-spawn';
import * as poetryUtils from '../../provider/poetry/utils';

describe('nx-python enable-releases', () => {
let appTree: Tree;

beforeEach(() => {
appTree = createTreeWithEmptyWorkspace({});

vi.spyOn(poetryUtils, 'checkPoetryExecutable').mockReturnValue(undefined);
vi.mocked(spawn.sync).mockImplementation((command) => {
if (command === 'python') {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import {
updateProjectConfiguration,
} from '@nx/devkit';
import generator from '../../generators/poetry-project/generator';

import * as poetryUtils from '../../provider/poetry/utils';
import update from './replace-nx-run-commands';

describe('16-1-0-replace-nx-run-commands migration', () => {
let tree: Tree;

beforeEach(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });

vi.spyOn(poetryUtils, 'checkPoetryExecutable').mockReturnValue(undefined);
});

it('should run successfully', async () => {
Expand Down

0 comments on commit 31e1096

Please sign in to comment.