Skip to content

Commit

Permalink
Add recover to fail datasource test on cty panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilken Rivera authored and nywilken committed Apr 25, 2023
1 parent 21a1e5e commit b08070c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 0 additions & 2 deletions rpc/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
)

var b testing.B

func TestCommonServer_ConfigSpec(t *testing.T) {
tt := []struct {
name string
Expand Down
6 changes: 6 additions & 0 deletions rpc/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ func TestDatasource(t *testing.T) {
d.outputSpec = map[string]hcldec.Spec{
"foo": &hcldec.AttrSpec{Name: "foo", Type: cty.String, Required: false},
}

defer func() {
if r := recover(); r != nil {
t.Errorf("Call to ConfigSpec for datasource panicked: %v", r)
}
}()
spec := dsClient.OutputSpec()
if !reflect.DeepEqual(spec, d.outputSpec) {
t.Fatalf("unknown outputSpec value: %#v", spec)
Expand Down

0 comments on commit b08070c

Please sign in to comment.