2022-03-31 21:24:00 +00:00
|
|
|
package gitea
|
|
|
|
|
2022-07-09 21:11:26 +00:00
|
|
|
/*func TestAccDataSourceGiteaUser_basic(t *testing.T) {
|
2022-03-31 21:24:00 +00:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
// Get user using its username
|
|
|
|
{
|
|
|
|
Config: testAccDataGiteaUserConfigUsername(),
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccDataSourceGiteaUser("data.gitea_user.foo"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Config: testAccDataGiteaUserConfigUsername(),
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testAccDataSourceGiteaUser("data.gitea_user.self"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func testAccDataSourceGiteaUser(src string) resource.TestCheckFunc {
|
|
|
|
return func(s *terraform.State) error {
|
|
|
|
|
|
|
|
user := s.RootModule().Resources[src]
|
|
|
|
userResource := user.Primary.Attributes
|
|
|
|
|
|
|
|
testAttributes := []string{
|
|
|
|
"username",
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, attribute := range testAttributes {
|
|
|
|
if userResource[attribute] != "test01" {
|
|
|
|
return fmt.Errorf("Expected user's parameter `%s` to be: %s, but got: `%s`", attribute, userResource[attribute], "test01")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testAccDataGiteaUserConfigUsername() string {
|
|
|
|
return fmt.Sprintf(`
|
|
|
|
data "gitea_user" "foo" {
|
|
|
|
username = "test01"
|
|
|
|
}
|
|
|
|
data "gitea_user" "self" {
|
|
|
|
}
|
|
|
|
`)
|
2022-07-09 21:11:26 +00:00
|
|
|
}*/
|