-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1550 from hashicorp/simonxmh/add_project_level_au…
…to_destroy Add project level auto destroy
- Loading branch information
Showing
13 changed files
with
399 additions
and
40 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
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
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
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
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
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
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 |
---|---|---|
|
@@ -129,6 +129,43 @@ func TestAccTFEProject_import(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccTFEProject_withAutoDestroy(t *testing.T) { | ||
project := &tfe.Project{} | ||
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int() | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckTFEProjectDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccTFEProject_basicWithAutoDestroy(rInt, "3d"), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckTFEProjectExists( | ||
"tfe_project.foobar", project), | ||
testAccCheckTFEProjectAttributes(project), | ||
resource.TestCheckResourceAttr( | ||
"tfe_project.foobar", "auto_destroy_activity_duration", "3d"), | ||
), | ||
}, | ||
{ | ||
Config: testAccTFEProject_basicWithAutoDestroy(rInt, "10m"), | ||
ExpectError: regexp.MustCompile(`must be 1-4 digits followed by d or h`), | ||
}, | ||
{ | ||
Config: testAccTFEProject_basic(rInt), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckTFEProjectExists( | ||
"tfe_project.foobar", project), | ||
testAccCheckTFEProjectAttributes(project), | ||
resource.TestCheckResourceAttr( | ||
"tfe_project.foobar", "auto_destroy_activity_duration", ""), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccTFEProject_update(rInt int) string { | ||
return fmt.Sprintf(` | ||
resource "tfe_organization" "foobar" { | ||
|
@@ -182,6 +219,20 @@ resource "tfe_project" "foobar" { | |
}`, rInt) | ||
} | ||
|
||
func testAccTFEProject_basicWithAutoDestroy(rInt int, duration string) string { | ||
return fmt.Sprintf(` | ||
resource "tfe_organization" "foobar" { | ||
name = "tst-terraform-%d" | ||
email = "[email protected]" | ||
} | ||
resource "tfe_project" "foobar" { | ||
organization = tfe_organization.foobar.name | ||
name = "projecttest" | ||
auto_destroy_activity_duration = "%s" | ||
}`, rInt, duration) | ||
} | ||
|
||
func testAccCheckTFEProjectDestroy(s *terraform.State) error { | ||
config := testAccProvider.Meta().(ConfiguredClient) | ||
|
||
|
Oops, something went wrong.