-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aws: Add acceptance tests for "aws_codedeploy_app" resources.
- Loading branch information
Showing
1 changed file
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package aws | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/service/codedeploy" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
"github.com/hashicorp/terraform/terraform" | ||
) | ||
|
||
func TestAccAWSCodeDeployApp_basic(t *testing.T) { | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSCodeDeployAppDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
Config: testAccAWSCodeDeployApp, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSCodeDeployAppExists("aws_codedeploy_app.foo"), | ||
), | ||
}, | ||
resource.TestStep{ | ||
Config: testAccAWSCodeDeployAppModifier, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSCodeDeployAppExists("aws_codedeploy_app.foo"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAWSCodeDeployAppDestroy(s *terraform.State) error { | ||
conn := testAccProvider.Meta().(*AWSClient).codedeployconn | ||
|
||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type != "aws_codedeploy_app" { | ||
continue | ||
} | ||
|
||
resp, err := conn.GetApplication(&codedeploy.GetApplicationInput{ | ||
ApplicationName: aws.String(rs.Primary.ID), | ||
}) | ||
|
||
if err == nil { | ||
if resp.Application != nil { | ||
return fmt.Errorf("CodeDeploy app still exists:\n%#v", *resp.Application.ApplicationID) | ||
} | ||
} | ||
|
||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func testAccCheckAWSCodeDeployAppExists(name string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
_, ok := s.RootModule().Resources[name] | ||
if !ok { | ||
return fmt.Errorf("Not found: %s", name) | ||
} | ||
|
||
return nil | ||
} | ||
} | ||
|
||
var testAccAWSCodeDeployApp = ` | ||
resource "aws_codedeploy_app" "foo" { | ||
name = "foo" | ||
}` | ||
|
||
var testAccAWSCodeDeployAppModifier = ` | ||
resource "aws_codedeploy_app" "foo" { | ||
name = "bar" | ||
}` |