-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for windows_local_group_members data-source
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
internal/provider/local/local_group_members_data_source_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,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$`)), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |