Tighten up auto test (#7830)

* Tighten up a test to not fail for wrong reasons, use python helpers

* Use local in-source Python SDK for the test
This commit is contained in:
Anton Tayanovskyy 2021-08-24 14:48:09 -04:00 committed by GitHub
parent 1b67c9ee52
commit b667ce5d4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 7 deletions

View file

@ -23,6 +23,7 @@ import (
"time"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/python"
"github.com/stretchr/testify/assert"
)
@ -369,13 +370,30 @@ func TestRuntimeErrorPython(t *testing.T) {
stackName := FullyQualifiedStackName(pulumiOrg, runtimeErrProj, sName)
// initialize
pDir := filepath.Join(".", "test", "errors", "runtime_error", "python")
cmd := exec.Command("python3", "-m", "venv", "venv")
cmd.Dir = pDir
err := cmd.Run()
pDir, err := filepath.Abs(filepath.Join(".", "test", "errors", "runtime_error", "python"))
if err != nil {
t.Errorf("failed to install project dependencies")
t.Error(err)
t.FailNow()
}
err = python.InstallDependencies(pDir, "venv", true /*showOutput*/)
if err != nil {
t.Errorf("failed to create a venv and install project dependencies: %v", err)
t.FailNow()
}
pySDK, err := filepath.Abs(filepath.Join("..", "..", "..", "sdk", "python", "env", "src"))
if err != nil {
t.Error(err)
t.FailNow()
}
// install Pulumi Python SDK from the current source tree, -e means no-copy, ref directly
pyCmd := python.VirtualEnvCommand(filepath.Join(pDir, "venv"), "python", "-m", "pip", "install", "-e", pySDK)
pyCmd.Dir = pDir
err = pyCmd.Run()
if err != nil {
t.Errorf("failed to link venv against in-source pulumi: %v", err)
t.FailNow()
}
@ -394,6 +412,7 @@ func TestRuntimeErrorPython(t *testing.T) {
_, err = s.Up(ctx)
assert.NotNil(t, err)
assert.True(t, IsRuntimeError(err), "%+v", err)
assert.Contains(t, fmt.Sprintf("%v", err), "IndexError: list index out of range")
// -- pulumi destroy --

View file

@ -1 +1 @@
pulumi>=2.0.0,<3.0.0