modify aws_iam_user_test to correctly check username and path for initial and changed username/path

This commit is contained in:
Patrick Gray 2015-11-10 15:24:45 -05:00
parent 37e280f6be
commit eadee6bd33
1 changed files with 6 additions and 6 deletions

View File

@ -23,14 +23,14 @@ func TestAccAWSUser_basic(t *testing.T) {
Config: testAccAWSUserConfig, Config: testAccAWSUserConfig,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSUserExists("aws_iam_user.user", &conf), testAccCheckAWSUserExists("aws_iam_user.user", &conf),
testAccCheckAWSUserAttributes(&conf), testAccCheckAWSUserAttributes(&conf, "test-user", "/"),
), ),
}, },
resource.TestStep{ resource.TestStep{
Config: testAccAWSUserConfig2, Config: testAccAWSUserConfig2,
Check: resource.ComposeTestCheckFunc( Check: resource.ComposeTestCheckFunc(
testAccCheckAWSUserExists("aws_iam_user.user", &conf), 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 { 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) 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) return fmt.Errorf("Bad path: %s", *user.User.Path)
} }
@ -115,6 +115,6 @@ resource "aws_iam_user" "user" {
const testAccAWSUserConfig2 = ` const testAccAWSUserConfig2 = `
resource "aws_iam_user" "user" { resource "aws_iam_user" "user" {
name = "test-user2" name = "test-user2"
path = "/balls/" path = "/path2/"
} }
` `