modify aws_iam_user_test to correctly check username and path for initial and changed username/path
This commit is contained in:
parent
37e280f6be
commit
eadee6bd33
|
@ -23,14 +23,14 @@ func TestAccAWSUser_basic(t *testing.T) {
|
|||
Config: testAccAWSUserConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSUserExists("aws_iam_user.user", &conf),
|
||||
testAccCheckAWSUserAttributes(&conf),
|
||||
testAccCheckAWSUserAttributes(&conf, "test-user", "/"),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccAWSUserConfig2,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckAWSUserExists("aws_iam_user.user", &conf),
|
||||
testAccCheckAWSUserAttributes(&conf),
|
||||
testAccCheckAWSUserAttributes(&conf, "test-user2", "/path2/"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -92,13 +92,13 @@ func testAccCheckAWSUserExists(n string, res *iam.GetUserOutput) resource.TestCh
|
|||
}
|
||||
}
|
||||
|
||||
func testAccCheckAWSUserAttributes(user *iam.GetUserOutput) resource.TestCheckFunc {
|
||||
func testAccCheckAWSUserAttributes(user *iam.GetUserOutput, name string, path string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
if *user.User.UserName != "test-user" {
|
||||
if *user.User.UserName != name {
|
||||
return fmt.Errorf("Bad name: %s", *user.User.UserName)
|
||||
}
|
||||
|
||||
if *user.User.Path != "/" {
|
||||
if *user.User.Path != path {
|
||||
return fmt.Errorf("Bad path: %s", *user.User.Path)
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,6 @@ resource "aws_iam_user" "user" {
|
|||
const testAccAWSUserConfig2 = `
|
||||
resource "aws_iam_user" "user" {
|
||||
name = "test-user2"
|
||||
path = "/balls/"
|
||||
path = "/path2/"
|
||||
}
|
||||
`
|
||||
|
|
Loading…
Reference in New Issue