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:
parent
1b67c9ee52
commit
b667ce5d4f
|
@ -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 --
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
pulumi>=2.0.0,<3.0.0
|
||||
|
||||
|
|
Loading…
Reference in a new issue