Skip to content

Commit

Permalink
Update provider functions testing docs to help users avoid nil pointe…
Browse files Browse the repository at this point in the history
…r error (#940)

* Fix capitalisation

* Update example test to mitigate nil pointer error

See #928

* Update website/docs/plugin/framework/functions/testing.mdx

Co-authored-by: Austin Valle <austinvalle@gmail.com>

* Update website/docs/plugin/framework/functions/testing.mdx

Co-authored-by: Austin Valle <austinvalle@gmail.com>

* Update website/docs/plugin/framework/functions/testing.mdx

Co-authored-by: Austin Valle <austinvalle@gmail.com>

* Update website/docs/plugin/framework/functions/testing.mdx

Co-authored-by: Austin Valle <austinvalle@gmail.com>

* Update website/docs/plugin/framework/functions/testing.mdx

Co-authored-by: Austin Valle <austinvalle@gmail.com>

---------

Co-authored-by: Austin Valle <austinvalle@gmail.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
  • Loading branch information
3 people committed Mar 1, 2024
1 parent bd22b58 commit 1597a95
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions website/docs/plugin/framework/functions/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ func TestEchoFunctionRun(t *testing.T) {
// this test case shows how the function would be expected to behave.
"null": {
request: function.RunRequest{
Arguments: function.NewArgumentsData(types.StringNull()),
Arguments: function.NewArgumentsData([]attr.Value{types.StringNull()}),
},
Expected: function.RunResponse{
expected: function.RunResponse{
Result: function.NewResultData(types.StringNull()),
},
},
Expand All @@ -181,17 +181,17 @@ func TestEchoFunctionRun(t *testing.T) {
// this test case shows how the function would be expected to behave.
"unknown": {
request: function.RunRequest{
Arguments: function.NewArgumentsData(types.StringUnknown()),
Arguments: function.NewArgumentsData([]attr.Value{types.StringUnknown()}),
},
Expected: function.RunResponse{
expected: function.RunResponse{
Result: function.NewResultData(types.StringUnknown()),
},
},
"value-valid": {
request: function.RunRequest{
Arguments: function.NewArgumentsData(types.StringValue("test-value")),
Arguments: function.NewArgumentsData([]attr.Value{types.StringValue("test-value")}),
},
Expected: function.RunResponse{
expected: function.RunResponse{
Result: function.NewResultData(types.StringValue("test-value")),
},
},
Expand All @@ -200,9 +200,9 @@ func TestEchoFunctionRun(t *testing.T) {
// it did.
"value-invalid": {
request: function.RunRequest{
Arguments: function.NewArgumentsData(types.StringValue()),
Arguments: function.NewArgumentsData([]attr.Value{types.StringValue("")}),
},
Expected: function.RunResponse{
expected: function.RunResponse{
Error: function.NewArgumentFuncError(0, "error summary: error detail"),
Result: function.NewResultData(types.StringUnknown()),
},
Expand All @@ -215,7 +215,9 @@ func TestEchoFunctionRun(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()

got := function.RunResponse{}
got := function.RunResponse{
Result: function.NewResultData(types.StringUnknown()),
}

provider.EchoFunction{}.Run(context.Background(), testCase.request, &got)

Expand Down

0 comments on commit 1597a95

Please sign in to comment.