Skip to content

Commit 5c1f575

Browse files
committed
delete duplicate tests and add name params
1 parent c91b157 commit 5c1f575

File tree

1 file changed

+40
-87
lines changed

1 file changed

+40
-87
lines changed

function/definition_test.go

+40-87
Original file line numberDiff line numberDiff line change
@@ -243,101 +243,52 @@ func TestDefinitionValidateImplementation(t *testing.T) {
243243
definition: function.Definition{
244244
Parameters: []function.Parameter{
245245
function.MapParameter{
246+
Name: "map_with_dynamic",
246247
ElementType: types.DynamicType,
247248
},
248249
},
249250
Return: function.StringReturn{},
250251
},
251-
expected: diag.Diagnostics{
252-
diag.NewErrorDiagnostic(
253-
"Invalid Function Definition",
254-
"When validating the function definition, an implementation issue was found. "+
255-
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
256-
"Parameter \"param1\" at position 0 contains a collection type with a nested dynamic type.\n\n"+
257-
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
258-
"If underlying dynamic values are required, replace the \"param1\" parameter definition with DynamicParameter instead.",
259-
),
260-
},
261-
},
262-
"variadic-param-dynamic-in-collection": {
263-
definition: function.Definition{
264-
Parameters: []function.Parameter{
265-
function.StringParameter{},
266-
function.StringParameter{},
267-
},
268-
VariadicParameter: function.SetParameter{
269-
ElementType: types.DynamicType,
270-
},
271-
Return: function.StringReturn{},
272-
},
273-
expected: diag.Diagnostics{
274-
diag.NewErrorDiagnostic(
275-
"Invalid Function Definition",
276-
"When validating the function definition, an implementation issue was found. "+
277-
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
278-
"Variadic parameter \"varparam\" contains a collection type with a nested dynamic type.\n\n"+
279-
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
280-
"If underlying dynamic values are required, replace the variadic parameter definition with DynamicParameter instead.",
281-
),
282-
},
283-
},
284-
"return-dynamic-in-collection": {
285-
definition: function.Definition{
286-
Return: function.ListReturn{
287-
ElementType: types.DynamicType,
288-
},
289-
},
290-
expected: diag.Diagnostics{
291-
diag.NewErrorDiagnostic(
292-
"Invalid Function Definition",
293-
"When validating the function definition, an implementation issue was found. "+
294-
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
295-
"Return contains a collection type with a nested dynamic type.\n\n"+
296-
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
297-
"If underlying dynamic values are required, replace the return definition with DynamicReturn instead.",
298-
),
299-
},
300-
},
301-
"param-dynamic-in-collection": {
302-
definition: function.Definition{
303-
Parameters: []function.Parameter{
304-
function.MapParameter{
305-
ElementType: types.DynamicType,
306-
},
252+
expected: function.DefinitionValidateResponse{
253+
Diagnostics: diag.Diagnostics{
254+
diag.NewErrorDiagnostic(
255+
"Invalid Function Definition",
256+
"When validating the function definition, an implementation issue was found. "+
257+
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
258+
"Parameter \"map_with_dynamic\" at position 0 contains a collection type with a nested dynamic type.\n\n"+
259+
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
260+
"If underlying dynamic values are required, replace the \"map_with_dynamic\" parameter definition with DynamicParameter instead.",
261+
),
307262
},
308-
Return: function.StringReturn{},
309-
},
310-
expected: diag.Diagnostics{
311-
diag.NewErrorDiagnostic(
312-
"Invalid Function Definition",
313-
"When validating the function definition, an implementation issue was found. "+
314-
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
315-
"Parameter \"param1\" at position 0 contains a collection type with a nested dynamic type.\n\n"+
316-
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
317-
"If underlying dynamic values are required, replace the \"param1\" parameter definition with DynamicParameter instead.",
318-
),
319263
},
320264
},
321265
"variadic-param-dynamic-in-collection": {
322266
definition: function.Definition{
323267
Parameters: []function.Parameter{
324-
function.StringParameter{},
325-
function.StringParameter{},
268+
function.StringParameter{
269+
Name: "string_param1",
270+
},
271+
function.StringParameter{
272+
Name: "string_param2",
273+
},
326274
},
327275
VariadicParameter: function.SetParameter{
276+
Name: "set_with_dynamic",
328277
ElementType: types.DynamicType,
329278
},
330279
Return: function.StringReturn{},
331280
},
332-
expected: diag.Diagnostics{
333-
diag.NewErrorDiagnostic(
334-
"Invalid Function Definition",
335-
"When validating the function definition, an implementation issue was found. "+
336-
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
337-
"Variadic parameter \"varparam\" contains a collection type with a nested dynamic type.\n\n"+
338-
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
339-
"If underlying dynamic values are required, replace the variadic parameter definition with DynamicParameter instead.",
340-
),
281+
expected: function.DefinitionValidateResponse{
282+
Diagnostics: diag.Diagnostics{
283+
diag.NewErrorDiagnostic(
284+
"Invalid Function Definition",
285+
"When validating the function definition, an implementation issue was found. "+
286+
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
287+
"Variadic parameter \"set_with_dynamic\" contains a collection type with a nested dynamic type.\n\n"+
288+
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
289+
"If underlying dynamic values are required, replace the variadic parameter definition with DynamicParameter instead.",
290+
),
291+
},
341292
},
342293
},
343294
"return-dynamic-in-collection": {
@@ -346,15 +297,17 @@ func TestDefinitionValidateImplementation(t *testing.T) {
346297
ElementType: types.DynamicType,
347298
},
348299
},
349-
expected: diag.Diagnostics{
350-
diag.NewErrorDiagnostic(
351-
"Invalid Function Definition",
352-
"When validating the function definition, an implementation issue was found. "+
353-
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
354-
"Return contains a collection type with a nested dynamic type.\n\n"+
355-
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
356-
"If underlying dynamic values are required, replace the return definition with DynamicReturn instead.",
357-
),
300+
expected: function.DefinitionValidateResponse{
301+
Diagnostics: diag.Diagnostics{
302+
diag.NewErrorDiagnostic(
303+
"Invalid Function Definition",
304+
"When validating the function definition, an implementation issue was found. "+
305+
"This is always an issue with the provider and should be reported to the provider developers.\n\n"+
306+
"Return contains a collection type with a nested dynamic type.\n\n"+
307+
"Dynamic types inside of collections are not currently supported in terraform-plugin-framework. "+
308+
"If underlying dynamic values are required, replace the return definition with DynamicReturn instead.",
309+
),
310+
},
358311
},
359312
},
360313
"conflicting-param-names": {

0 commit comments

Comments
 (0)