diff options
author | Nate Sesti <33237525+sestinj@users.noreply.github.com> | 2023-08-07 19:32:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-07 19:32:55 -0700 |
commit | de1bea106850c6ad4f7d6447faa434b953a462e8 (patch) | |
tree | 9c270065157e7611519ef2af8ff1e272a4ac728b /extension/src/activation/test | |
parent | 34157ba9c6de24a5321b81716d31bc89e8b96471 (diff) | |
parent | d8f5f102f6f91487be0281316e581858ec4ca260 (diff) | |
download | sncontinue-de1bea106850c6ad4f7d6447faa434b953a462e8.tar.gz sncontinue-de1bea106850c6ad4f7d6447faa434b953a462e8.tar.bz2 sncontinue-de1bea106850c6ad4f7d6447faa434b953a462e8.zip |
Merge pull request #356 from bra1nDump/fix-testing
Fixed Mocha tests + added debugging configurations to vscode
Diffstat (limited to 'extension/src/activation/test')
-rw-r--r-- | extension/src/activation/test/environmentSetup.test.ts | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/extension/src/activation/test/environmentSetup.test.ts b/extension/src/activation/test/environmentSetup.test.ts deleted file mode 100644 index ca487416..00000000 --- a/extension/src/activation/test/environmentSetup.test.ts +++ /dev/null @@ -1,70 +0,0 @@ -const child_process = require("child_process"); -import { platform } from "os"; -import { getPythonPipCommands } from "../environmentSetup"; - -jest.mock("os"); -jest.mock("child_process"); - -function mockPythonVersionMappings(mappings: { [pythonCmd: string]: string }) { - (child_process.exec as jest.Mock).mockImplementation( - (command: string, options: any) => { - const pythonCmd = command.split(" ")[0]; - if (pythonCmd in mappings) { - return Promise.resolve([mappings[pythonCmd], ""]); - } else { - return Promise.resolve(["", stubStderr]); - } - } - ); -} - -const stubStderr = - "This is a stub stderr, but will be checked only for existence."; -describe("getPythonPipCommands", () => { - describe("on Windows", () => { - it("should return the correct Python and Pip commands", async () => { - (platform as jest.Mock).mockReturnValue("win32"); - mockPythonVersionMappings({ - python: "Python 3.8.0", - }); - - const [pythonCmd, pipCmd] = await getPythonPipCommands(); - - expect(pythonCmd).toBe("python"); - expect(pipCmd).toBe("pip"); - - jest.restoreAllMocks(); - }); - describe("on MacOS", () => { - (platform as jest.Mock).mockReturnValue("darwin"); - it("should check through all python versions after finding 3.7", async () => { - mockPythonVersionMappings({ - python: "", - python3: "Python 3.7.0", - "python3.11": "Python 3.11.0", - }); - - const [pythonCmd, pipCmd] = await getPythonPipCommands(); - - expect(pythonCmd).toBe("python3.11"); - expect(pipCmd).toBe("pip3.11"); - - jest.restoreAllMocks(); - }); - - it("should use python3 if that maps to valid version", async () => { - mockPythonVersionMappings({ - python: "", - python3: "Python 3.8.0", - }); - - const [pythonCmd, pipCmd] = await getPythonPipCommands(); - - expect(pythonCmd).toBe("python3"); - expect(pipCmd).toBe("pip3"); - - jest.restoreAllMocks(); - }); - }); - }); -}); |