Skip to content

Commit

Permalink
Develop (#6)
Browse files Browse the repository at this point in the history
* add acctest

* refactor the acctest

* debugging acc-test

* checking on acc-test

* passing identity test

---------

Co-authored-by: [email protected] <[email protected]>
  • Loading branch information
leasley199 and [email protected] authored Mar 13, 2024
1 parent 2934337 commit 7f79997
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func testIdentityGroupDataSource(t *testing.T, groupName string) {
Config: createIdentityGroupConfig(groupName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(tfNode, "id"),
resource.TestCheckResourceAttr(tfNode, "name", groupName),
resource.TestCheckResourceAttr(tfNode, "name", "[default]\\Contributors"),
),
},
},
Expand All @@ -37,12 +37,12 @@ data "azuredevops_project" "project" {
}
data "azuredevops_identity_group" "test" {
name = "%[1]s"
name = "[default]\\%[1]s"
project_id = data.azuredevops_project.project.id
}`, groupName)
}

func TestAccIdentityGroupDataSource(t *testing.T) {
groupName := "[default]\\\\Contributors"
groupName := "Contributors"
testIdentityGroupDataSource(t, groupName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func testIdentityGroupsDataSource(t *testing.T, projectName string) {
Config: generateIdentityGroupsDataSourceConfig(projectName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(tfNode, "project_id"),
resource.TestCheckResourceAttrSet(tfNode, "groups.#"),
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func dataSourceIdentityGroupRead(d *schema.ResourceData, m interface{}) error {
// Set ID and descriptor for group data resource based on targetGroup output.
targetGroupID := targetGroup.Id.String()
d.SetId(targetGroupID)
d.Set("descriptor", targetGroup.Id)
d.Set("descriptor", targetGroupID)
return nil
}

Expand Down
7 changes: 3 additions & 4 deletions azuredevops/internal/service/identity/data_identity_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ func flattenIdentityGroups(groups *[]identity.Identity) ([]interface{}, error) {
groupMap := make(map[string]interface{})

if group.Id != nil {
groupMap["id"] = *group.Id
groupID := *group.Id
groupMap["id"] = groupID.String()
} else {
return nil, fmt.Errorf("Group Object does not contain an id")
}
Expand All @@ -99,7 +100,5 @@ func flattenIdentityGroups(groups *[]identity.Identity) ([]interface{}, error) {
}

func getIdentityGroupHash(v interface{}) int {
group := v.(map[string]interface{})
groupID := group["id"].(string)
return tfhelper.HashString(groupID)
return tfhelper.HashString(v.(map[string]interface{})["id"].(string))
}

0 comments on commit 7f79997

Please sign in to comment.