From 31e1096b51f4c63529bf8aa62f1ba2f44c2bc1b5 Mon Sep 17 00:00:00 2001 From: Lucas Vieira Date: Fri, 13 Dec 2024 11:47:51 -0300 Subject: [PATCH] test(nx-python): mock checkPoetryExecutable in executor and generator tests --- packages/nx-python/src/executors/sls-deploy/executor.spec.ts | 2 ++ packages/nx-python/src/executors/sls-package/executor.spec.ts | 2 ++ .../src/generators/enable-releases/generator.spec.ts | 3 +++ .../migrations/update-16-1-0/replace-nx-run-commands.spec.ts | 4 +++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/nx-python/src/executors/sls-deploy/executor.spec.ts b/packages/nx-python/src/executors/sls-deploy/executor.spec.ts index b85803b..52ac58e 100644 --- a/packages/nx-python/src/executors/sls-deploy/executor.spec.ts +++ b/packages/nx-python/src/executors/sls-deploy/executor.spec.ts @@ -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 () => { diff --git a/packages/nx-python/src/executors/sls-package/executor.spec.ts b/packages/nx-python/src/executors/sls-package/executor.spec.ts index 6a967fe..a2bb4e9 100644 --- a/packages/nx-python/src/executors/sls-package/executor.spec.ts +++ b/packages/nx-python/src/executors/sls-package/executor.spec.ts @@ -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 () => { diff --git a/packages/nx-python/src/generators/enable-releases/generator.spec.ts b/packages/nx-python/src/generators/enable-releases/generator.spec.ts index 80ec675..bd17609 100644 --- a/packages/nx-python/src/generators/enable-releases/generator.spec.ts +++ b/packages/nx-python/src/generators/enable-releases/generator.spec.ts @@ -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 { diff --git a/packages/nx-python/src/migrations/update-16-1-0/replace-nx-run-commands.spec.ts b/packages/nx-python/src/migrations/update-16-1-0/replace-nx-run-commands.spec.ts index b7d89bc..7234577 100644 --- a/packages/nx-python/src/migrations/update-16-1-0/replace-nx-run-commands.spec.ts +++ b/packages/nx-python/src/migrations/update-16-1-0/replace-nx-run-commands.spec.ts @@ -5,7 +5,7 @@ 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', () => { @@ -13,6 +13,8 @@ describe('16-1-0-replace-nx-run-commands migration', () => { beforeEach(() => { tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); + + vi.spyOn(poetryUtils, 'checkPoetryExecutable').mockReturnValue(undefined); }); it('should run successfully', async () => {