Skip to content

Commit

Permalink
provider/aws: Add tests for default_branch in new codecommit repos
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
keymon committed Mar 30, 2016
1 parent 0c49b17 commit 29c9b84
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions builtin/providers/aws/resource_aws_codecommit_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"
}
`

0 comments on commit 29c9b84

Please sign in to comment.