forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
providers/heroku: import heroku_app resource (hashicorp#14248)
Adds support for importing normal and organization apps with the heroku_app resource. The resource itself depends on an `organization` value in the configuration to switch behavior for the different kinds of apps, so `schema.ImportStatePassthrough` is not sufficient.
- Loading branch information
1 parent
695d014
commit 74c3a6d
Showing
2 changed files
with
80 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,58 @@ | ||
package heroku | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform/helper/acctest" | ||
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccHerokuApp_importBasic(t *testing.T) { | ||
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10)) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckHerokuAppDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckHerokuAppConfig_basic(appName), | ||
}, | ||
{ | ||
ResourceName: "heroku_app.foobar", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"config_vars"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccHerokuApp_importOrganization(t *testing.T) { | ||
appName := fmt.Sprintf("tftest-%s", acctest.RandString(10)) | ||
org := os.Getenv("HEROKU_ORGANIZATION") | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
if org == "" { | ||
t.Skip("HEROKU_ORGANIZATION is not set; skipping test.") | ||
} | ||
}, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckHerokuAppDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckHerokuAppConfig_organization(appName, org), | ||
}, | ||
{ | ||
ResourceName: "heroku_app.foobar", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"config_vars"}, | ||
}, | ||
}, | ||
}) | ||
} |
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