-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from colesgroup/MADM-312-azuredevops-addition…
…al-branch-policy-settings-in-the-terraform-provider azuredevops additional branch policy settings in the terraform provider
- Loading branch information
Showing
7 changed files
with
174 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
azuredevops/internal/service/policy/resource_branchpolicy_min_reviewers_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// +build all resource_branchpolicy_min_reviewers | ||
// +build !exclude_resource_branchpolicy_min_reviewers | ||
|
||
package policy | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/google/uuid" | ||
"github.com/microsoft/azure-devops-go-api/azuredevops/policy" | ||
"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/converter" | ||
) | ||
|
||
// verifies that the flatten/expand round trip path produces repeatable results | ||
func TestBranchPolicyMinReviewers_ExpandFlatten_Roundtrip(t *testing.T) { | ||
var projectID = uuid.New().String() | ||
var randomUUID = uuid.New() | ||
var testPolicy = &policy.PolicyConfiguration{ | ||
Id: converter.Int(1), | ||
IsEnabled: converter.Bool(true), | ||
IsBlocking: converter.Bool(true), | ||
Type: &policy.PolicyTypeRef{ | ||
Id: &randomUUID, | ||
}, | ||
Settings: map[string]interface{}{ | ||
"scope": []map[string]interface{}{ | ||
{ | ||
"repositoryId": "test-repo-id", | ||
"refName": "test-ref-name", | ||
"matchKind": "test-match-kind", | ||
}, | ||
}, | ||
"minimumApproverCount": 2, | ||
"creatorVoteCounts": true, | ||
"allowDownvotes": true, | ||
"resetOnSourcePush": true, | ||
"requireVoteOnLastIteration": true, | ||
"resetRejectionsOnSourcePush": true, | ||
"blockLastPusherVote": true, | ||
}, | ||
} | ||
|
||
resourceData := schema.TestResourceDataRaw(t, ResourceBranchPolicyMinReviewers().Schema, nil) | ||
err := minReviewersFlattenFunc(resourceData, testPolicy, &projectID) | ||
require.Nil(t, err) | ||
expandedPolicy, expandedProjectID, err := minReviewersExpandFunc(resourceData, randomUUID) | ||
require.Nil(t, err) | ||
|
||
require.Equal(t, testPolicy, expandedPolicy) | ||
require.Equal(t, projectID, *expandedProjectID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters