Skip to content

Commit

Permalink
test: add test for data-source windows_local_group
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed Sep 26, 2024
1 parent 885a2e4 commit 5ffa632
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions internal/provider/local/local_group_data_source_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package local_test

import (
"testing"

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

func TestAccLocalGroupDataSource(t *testing.T) {
resource.Test(t, resource.TestCase{
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Check if the data source works with name
{
Config: acctest.ProviderConfig() + `
data "windows_local_group" "test" {
name = "Administrators"
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.windows_local_group.test", "id", "S-1-5-32-544"),
resource.TestCheckResourceAttr("data.windows_local_group.test", "sid", "S-1-5-32-544"),
resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"),
resource.TestCheckResourceAttr("data.windows_local_group.test", "description", "Administrators have complete and unrestricted access to the computer/domain"),
),
},
// Check if the data source works with SID
{
Config: acctest.ProviderConfig() + `
data "windows_local_group" "test" {
sid = "S-1-5-32-544"
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.windows_local_group.test", "id", "S-1-5-32-544"),
resource.TestCheckResourceAttr("data.windows_local_group.test", "sid", "S-1-5-32-544"),
resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"),
resource.TestCheckResourceAttr("data.windows_local_group.test", "description", "Administrators have complete and unrestricted access to the computer/domain"),
),
},
},
})
}

// const testAccLocalGroupDataSourceConfig = `
// data "windows_local_group" "test" {
// name = "Administrators"
// }
// `

0 comments on commit 5ffa632

Please sign in to comment.