Skip to content

Commit

Permalink
test: add test for windows_local_group_members data-source
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed Sep 29, 2024
1 parent 9f37d2a commit fab8282
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internal/provider/local/local_group_members_data_source_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package local_test

import (
"regexp"
"testing"

"github.com/d-strobel/terraform-provider-windows/internal/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccLocalGroupMembersDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Read testing
{
Config: acctest.ProviderConfig() + `
data "windows_local_group_members" "test" {
name = "Administrators"
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.windows_local_group_members.test", "name", "Administrators"),
// Check first group in the list
resource.TestCheckResourceAttr("data.windows_local_group_members.test", "members.0.sid", "S-1-5-21-153895498-367353507-3704405138-500"),
resource.TestCheckResourceAttr("data.windows_local_group_members.test", "members.0.object_class", "User"),
resource.TestMatchResourceAttr("data.windows_local_group_members.test", "members.0.name", regexp.MustCompile(`Administrator$`)),
// Check second group in the list
resource.TestCheckResourceAttr("data.windows_local_group_members.test", "members.1.sid", "S-1-5-21-153895498-367353507-3704405138-1000"),
resource.TestCheckResourceAttr("data.windows_local_group_members.test", "members.1.object_class", "User"),
resource.TestMatchResourceAttr("data.windows_local_group_members.test", "members.1.name", regexp.MustCompile(`vagrant$`)),
),
},
},
})
}

0 comments on commit fab8282

Please sign in to comment.