-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpython.test.js
75 lines (64 loc) · 1.89 KB
/
python.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import Python from "./python"
import {
runAction,
runActionExpectError,
cleanPath,
Cleaner,
Mute,
ignoreInstalled,
} from "./testutil"
Mute.all()
describe("skipping slow tests", () => {
if (process.env.TEST_FAST) {
it.only("", () => {})
}
})
describe("runAction python", () => {
const cleaner = new Cleaner(Python)
afterEach(cleaner.clean)
it("works", async () => {
const desiredVersion = "3.10.2"
const env = {
INPUT_PYTHON: desiredVersion,
...ignoreInstalled(),
}
return runAction("index", env).then((proc) => {
expect(proc.stderr.toString()).toBe("")
expect(proc.stdout).toContain(`python --version: ${desiredVersion}`)
expect(proc.stdout).toContain("python success!")
})
})
it("fails with bad PYENV_ROOT", () => {
// This nonsense is to filter out pyenv if it's already on the path
const env = {
INPUT_PYTHON: "3.10.2",
PYENV_ROOT: "/tmp/.pyenv",
PATH: cleanPath("pyenv"),
...ignoreInstalled(),
}
return expect(
runActionExpectError("index", env).catch((err) => {
throw new Error(err.stdout)
}),
).rejects.toThrow(/::error::PYENV_ROOT misconfigured/)
})
})
describe("install", () => {
const cleaner = new Cleaner(Python)
afterEach(cleaner.clean)
it("works", async () => {
const root = Python.tempRoot()
cleaner.root = await new Python().install(root)
expect(cleaner.root).toMatch(/\/\.pyenv/)
})
})
describe("setup", () => {
const cleaner = new Cleaner(Python)
afterEach(cleaner.clean)
it("works with an override version", () => {
return new Python().setup("3.10.2")
})
it("is harmless if there's no versions", () => {
return new Python().setup()
})
})