Skip to content

Commit 67aa085

Browse files
Fail fast on provider binary missing (#135)
New error message sample: /newStack_test.go:16: creating stack test /newStack_test.go:16: failed to find binary for provider "gcp": stat /.../provider_directory/file_that_does_not_exist: no such file or directory Fixes #77
1 parent 4d93119 commit 67aa085

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

pulumitest/newStack.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ func (pt *PulumiTest) NewStack(t PT, stackName string, opts ...optnewstack.NewSt
107107
if err != nil {
108108
ptFatalF(t, "failed to get absolute path for %s: %s", relPath, err)
109109
}
110+
_, err = os.Stat(absPath)
111+
if err != nil {
112+
ptFatalF(t, "failed to find binary for provider %q: %s", name, err)
113+
return nil
114+
}
110115

111116
found := false
112117
for idx := range providerPlugins {

pulumitest/newStack_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package pulumitest_test
2+
3+
import (
4+
"path/filepath"
5+
"testing"
6+
7+
"github.com/pulumi/providertest/pulumitest"
8+
"github.com/pulumi/providertest/pulumitest/opttest"
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestMissingProviderBinaryPath(t *testing.T) {
13+
t.Parallel()
14+
15+
tt := mockT{T: t}
16+
pulumitest.NewPulumiTest(&tt, filepath.Join("testdata", "yaml_program"),
17+
opttest.LocalProviderPath("gcp", filepath.Join("provider_directory", "file_that_does_not_exist")),
18+
)
19+
20+
assert.True(t, tt.Failed(), "expected test to fail")
21+
}

0 commit comments

Comments
 (0)