provider/aws: Add tests for default_branch in new codecommit repos

The provider should, when working on a new repository without branches:
 * Able to create a new repository even with default_branch defined.
 * Able to create a new repository without default_branch, and do not fail
   if default_branch is defined.
This commit is contained in:
Hector Rivas Gandara 2016-03-30 16:03:37 +01:00
parent 0c49b17f72
commit 29c9b8497d
1 changed files with 55 additions and 0 deletions

View File

@ -53,6 +53,50 @@ func TestAccAWSCodeCommitRepository_withChanges(t *testing.T) {
})
}
func TestAccAWSCodeCommitRepository_create_default_branch(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCodeCommitRepositoryDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCodeCommitRepository_with_default_branch,
Check: resource.ComposeTestCheckFunc(
testAccCheckCodeCommitRepositoryExists("aws_codecommit_repository.test"),
resource.TestCheckResourceAttr(
"aws_codecommit_repository.test", "default_branch", "master"),
),
},
},
})
}
func TestAccAWSCodeCommitRepository_create_and_update_default_branch(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCodeCommitRepositoryDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccCodeCommitRepository_basic,
Check: resource.ComposeTestCheckFunc(
testAccCheckCodeCommitRepositoryExists("aws_codecommit_repository.test"),
resource.TestCheckResourceAttr(
"aws_codecommit_repository.test", "default_branch", ""),
),
},
resource.TestStep{
Config: testAccCodeCommitRepository_with_default_branch,
Check: resource.ComposeTestCheckFunc(
testAccCheckCodeCommitRepositoryExists("aws_codecommit_repository.test"),
resource.TestCheckResourceAttr(
"aws_codecommit_repository.test", "default_branch", "master"),
),
},
},
})
}
func testAccCheckCodeCommitRepositoryExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
@ -129,3 +173,14 @@ resource "aws_codecommit_repository" "test" {
description = "This is a test description - with changes"
}
`
const testAccCodeCommitRepository_with_default_branch = `
provider "aws" {
region = "us-east-1"
}
resource "aws_codecommit_repository" "test" {
repository_name = "my_test_repository"
description = "This is a test description"
default_branch = "master"
}
`