Skip to content

Commit 2282a46

Browse files
SarahFrenchaustinvallebflad
committed
Update provider functions testing docs to help users avoid nil pointer 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 <[email protected]> * Update website/docs/plugin/framework/functions/testing.mdx Co-authored-by: Austin Valle <[email protected]> * Update website/docs/plugin/framework/functions/testing.mdx Co-authored-by: Austin Valle <[email protected]> * Update website/docs/plugin/framework/functions/testing.mdx Co-authored-by: Austin Valle <[email protected]> * Update website/docs/plugin/framework/functions/testing.mdx Co-authored-by: Austin Valle <[email protected]> --------- Co-authored-by: Austin Valle <[email protected]> Co-authored-by: Brian Flad <[email protected]>
1 parent c4e9883 commit 2282a46

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

+11-9
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ func TestEchoFunctionRun(t *testing.T) {
170170
// this test case shows how the function would be expected to behave.
171171
"null": {
172172
request: function.RunRequest{
173-
Arguments: function.NewArgumentsData(types.StringNull()),
173+
Arguments: function.NewArgumentsData([]attr.Value{types.StringNull()}),
174174
},
175-
Expected: function.RunResponse{
175+
expected: function.RunResponse{
176176
Result: function.NewResultData(types.StringNull()),
177177
},
178178
},
@@ -181,17 +181,17 @@ func TestEchoFunctionRun(t *testing.T) {
181181
// this test case shows how the function would be expected to behave.
182182
"unknown": {
183183
request: function.RunRequest{
184-
Arguments: function.NewArgumentsData(types.StringUnknown()),
184+
Arguments: function.NewArgumentsData([]attr.Value{types.StringUnknown()}),
185185
},
186-
Expected: function.RunResponse{
186+
expected: function.RunResponse{
187187
Result: function.NewResultData(types.StringUnknown()),
188188
},
189189
},
190190
"value-valid": {
191191
request: function.RunRequest{
192-
Arguments: function.NewArgumentsData(types.StringValue("test-value")),
192+
Arguments: function.NewArgumentsData([]attr.Value{types.StringValue("test-value")}),
193193
},
194-
Expected: function.RunResponse{
194+
expected: function.RunResponse{
195195
Result: function.NewResultData(types.StringValue("test-value")),
196196
},
197197
},
@@ -200,9 +200,9 @@ func TestEchoFunctionRun(t *testing.T) {
200200
// it did.
201201
"value-invalid": {
202202
request: function.RunRequest{
203-
Arguments: function.NewArgumentsData(types.StringValue()),
203+
Arguments: function.NewArgumentsData([]attr.Value{types.StringValue("")}),
204204
},
205-
Expected: function.RunResponse{
205+
expected: function.RunResponse{
206206
Error: function.NewArgumentFuncError(0, "error summary: error detail"),
207207
Result: function.NewResultData(types.StringUnknown()),
208208
},
@@ -215,7 +215,9 @@ func TestEchoFunctionRun(t *testing.T) {
215215
t.Run(name, func(t *testing.T) {
216216
t.Parallel()
217217

218-
got := function.RunResponse{}
218+
got := function.RunResponse{
219+
Result: function.NewResultData(types.StringUnknown()),
220+
}
219221

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

0 commit comments

Comments
 (0)