Skip to content

Commit

Permalink
add test for on-demand install
Browse files Browse the repository at this point in the history
  • Loading branch information
julienp committed Aug 1, 2024
1 parent 3afced3 commit ee89b6a
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 42 deletions.
112 changes: 73 additions & 39 deletions tests/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,47 +129,81 @@ func TestKitchenSinkPythonVersions(t *testing.T) {
}
t.Parallel()

t.Run("defaults to 3.9", func(t *testing.T) {
copyTestData(t, "testdata/python-default")
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: "testdata/python-default",
Quick: true,
SkipRefresh: true,
PrepareProject: func(info *engine.Projinfo) error {
cmd := exec.Command("pulumi", "install")
cmd.Dir = info.Root
return cmd.Run()
},
})
})

t.Run("select 3.9", func(t *testing.T) {
copyTestData(t, "testdata/python-3.9")
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: "testdata/python-3.9",
Quick: true,
SkipRefresh: true,
PrepareProject: func(info *engine.Projinfo) error {
cmd := exec.Command("pulumi", "install")
cmd.Dir = info.Root
return cmd.Run()
},
dirs, err := testdata.ReadDir("testdata")
require.NoError(t, err)
for _, dir := range dirs {
dir := dir
t.Run(dir.Name(), func(t *testing.T) {
p := filepath.Join("testdata", dir.Name())
copyTestData(t, p)
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: p,
Quick: true,
SkipRefresh: true,
PrepareProject: func(info *engine.Projinfo) error {
cmd := exec.Command("pulumi", "install")
cmd.Dir = info.Root
return cmd.Run()
},
})
})
})
}

t.Run("select 3.12", func(t *testing.T) {
copyTestData(t, "testdata/python-3.12")
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: "testdata/python-3.12",
Quick: true,
SkipRefresh: true,
PrepareProject: func(info *engine.Projinfo) error {
cmd := exec.Command("pulumi", "install")
cmd.Dir = info.Root
return cmd.Run()
},
})
})
// t.Run("defaults to 3.9", func(t *testing.T) {
// copyTestData(t, "testdata/python-default")
// integration.ProgramTest(t, &integration.ProgramTestOptions{
// Dir: "testdata/python-default",
// Quick: true,
// SkipRefresh: true,
// PrepareProject: func(info *engine.Projinfo) error {
// cmd := exec.Command("pulumi", "install")
// cmd.Dir = info.Root
// return cmd.Run()
// },
// })
// })

// t.Run("select 3.9", func(t *testing.T) {
// copyTestData(t, "testdata/python-3.9")
// integration.ProgramTest(t, &integration.ProgramTestOptions{
// Dir: "testdata/python-3.9",
// Quick: true,
// SkipRefresh: true,
// PrepareProject: func(info *engine.Projinfo) error {
// cmd := exec.Command("pulumi", "install")
// cmd.Dir = info.Root
// return cmd.Run()
// },
// })
// })

// t.Run("select 3.12", func(t *testing.T) {
// copyTestData(t, "testdata/python-3.12")
// integration.ProgramTest(t, &integration.ProgramTestOptions{
// Dir: "testdata/python-3.12",
// Quick: true,
// SkipRefresh: true,
// PrepareProject: func(info *engine.Projinfo) error {
// cmd := exec.Command("pulumi", "install")
// cmd.Dir = info.Root
// return cmd.Run()
// },
// })
// })

// t.Run("select 3.10.2 - installs on demand", func(t *testing.T) {
// copyTestData(t, "testdata/python-3.10.2")
// integration.ProgramTest(t, &integration.ProgramTestOptions{
// Dir: "testdata/python-3.10.2",
// Quick: true,
// SkipRefresh: true,
// PrepareProject: func(info *engine.Projinfo) error {
// cmd := exec.Command("pulumi", "install")
// cmd.Dir = info.Root
// return cmd.Run()
// },
// })
// })
}

func TestCLIToolTests(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions tests/testdata/python-3.10.2/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10.2
6 changes: 6 additions & 0 deletions tests/testdata/python-3.10.2/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: "python-version-3.10.2"
runtime:
name: python
options:
toolchain: poetry
description: A Python program that checks the Python version. Install a precise version of Python that is not pre-installed.
4 changes: 4 additions & 0 deletions tests/testdata/python-3.10.2/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import sys

assert sys.version_info.major == 3 and sys.version_info.minor == 10 and sys.version_info.micro == 2 , \
f"version should be 3.10.2, got {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
10 changes: 10 additions & 0 deletions tests/testdata/python-3.10.2/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool]
[tool.poetry]
package-mode = false
[tool.poetry.dependencies]
pulumi = ">=3.0.0,<4.0.0"
python = "^3.8"
3 changes: 2 additions & 1 deletion tests/testdata/python-3.12/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys

assert sys.version_info.major == 3 and sys.version_info.minor == 12, "version should be 3.12"
assert sys.version_info.major == 3 and sys.version_info.minor == 12, \
f"version should be 3.12, got {sys.version_info.major}.{sys.version_info.minor}"
3 changes: 2 additions & 1 deletion tests/testdata/python-3.9/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys

assert sys.version_info.major == 3 and sys.version_info.minor == 9, "version should be 3.9"
assert sys.version_info.major == 3 and sys.version_info.minor == 9, \
f"version should be 3.9, got {sys.version_info.major}.{sys.version_info.minor}"
3 changes: 2 additions & 1 deletion tests/testdata/python-default/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys

assert sys.version_info.major == 3 and sys.version_info.minor == 9, "version should be 3.9"
assert sys.version_info.major == 3 and sys.version_info.minor == 9, \
f"version should be 3.9, got {sys.version_info.major}.{sys.version_info.minor}"

0 comments on commit ee89b6a

Please sign in to comment.