Refactored acceptance tests for iteration permissions in azuredevops/internal/acceptancetests/resource_iteration_permissions_test.go
@@ -7,28 +7,14 @@ import (
"fmt"
"testing"
- "github.com/ahmetb/go-linq"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/acceptancetests/testutils"
+ "github.com/terraform-providers/terraform-provider-azuredevops/azuredevops/internal/utils/datahelper"
)
func hclIterationPermissions(projectName string, permissions map[string]map[string]string) string {
- createPermissions := func(permissions map[string]string) string {
- return linq.From(permissions).
- Select(func(i interface{}) interface{} {
- kv := i.(linq.KeyValue)
- return fmt.Sprintf(`%s = "%s"`, kv.Key, kv.Value)
- }).
- Aggregate(func(r interface{}, i interface{}) interface{} {
- if r.(string) == "" {
- return i
- }
- return r.(string) + "\n" + i.(string)
- }).(string)
- }
-
- rootPermissions := createPermissions(permissions["root"])
- iterationPermissions := createPermissions(permissions["iteration"])
+ rootPermissions := datahelper.JoinMap(permissions["root"], "=", "\n")
+ iterationPermissions := datahelper.JoinMap(permissions["iteration"], "=", "\n")
return fmt.Sprintf(`
%s
