providers/heroku: tests passing, compiling
This commit is contained in:
parent
4a736b0dac
commit
64bc356f97
|
@ -8,7 +8,6 @@ import (
|
|||
|
||||
"github.com/cyberdelia/heroku-go/v3"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
// Global lock to prevent parallelism for heroku_addon since
|
||||
|
@ -116,9 +115,6 @@ func resourceHerokuAddonRead(d *schema.ResourceData, meta interface{}) error {
|
|||
d.Set("plan", plan)
|
||||
d.Set("provider_id", addon.ProviderID)
|
||||
d.Set("config_vars", []interface{}{addon.ConfigVars})
|
||||
d.SetDependencies([]terraform.ResourceDependency{
|
||||
terraform.ResourceDependency{ID: d.Get("app").(string)},
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -72,12 +72,12 @@ func TestAccHerokuAddon_noPlan(t *testing.T) {
|
|||
func testAccCheckHerokuAddonDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*heroku.Service)
|
||||
|
||||
for _, rs := range s.Resources {
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "heroku_addon" {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := client.AddonInfo(rs.Attributes["app"], rs.ID)
|
||||
_, err := client.AddonInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
|
||||
|
||||
if err == nil {
|
||||
return fmt.Errorf("Addon still exists")
|
||||
|
@ -100,25 +100,25 @@ func testAccCheckHerokuAddonAttributes(addon *heroku.Addon, n string) resource.T
|
|||
|
||||
func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.Resources[n]
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
}
|
||||
|
||||
if rs.ID == "" {
|
||||
if rs.Primary.ID == "" {
|
||||
return fmt.Errorf("No Addon ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*heroku.Service)
|
||||
|
||||
foundAddon, err := client.AddonInfo(rs.Attributes["app"], rs.ID)
|
||||
foundAddon, err := client.AddonInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if foundAddon.ID != rs.ID {
|
||||
if foundAddon.ID != rs.Primary.ID {
|
||||
return fmt.Errorf("Addon not found")
|
||||
}
|
||||
|
||||
|
|
|
@ -105,12 +105,12 @@ func TestAccHerokuApp_NukeVars(t *testing.T) {
|
|||
func testAccCheckHerokuAppDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*heroku.Service)
|
||||
|
||||
for _, rs := range s.Resources {
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "heroku_app" {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := client.AppInfo(rs.ID)
|
||||
_, err := client.AppInfo(rs.Primary.ID)
|
||||
|
||||
if err == nil {
|
||||
return fmt.Errorf("App still exists")
|
||||
|
@ -199,25 +199,25 @@ func testAccCheckHerokuAppAttributesNoVars(app *heroku.App) resource.TestCheckFu
|
|||
|
||||
func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.Resources[n]
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
}
|
||||
|
||||
if rs.ID == "" {
|
||||
if rs.Primary.ID == "" {
|
||||
return fmt.Errorf("No App Name is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*heroku.Service)
|
||||
|
||||
foundApp, err := client.AppInfo(rs.ID)
|
||||
foundApp, err := client.AppInfo(rs.Primary.ID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if foundApp.Name != rs.ID {
|
||||
if foundApp.Name != rs.Primary.ID {
|
||||
return fmt.Errorf("App not found")
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
"github.com/cyberdelia/heroku-go/v3"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func resourceHerokuDomain() *schema.Resource {
|
||||
|
@ -52,9 +51,6 @@ func resourceHerokuDomainCreate(d *schema.ResourceData, meta interface{}) error
|
|||
d.SetId(do.ID)
|
||||
d.Set("hostname", do.Hostname)
|
||||
d.Set("cname", fmt.Sprintf("%s.herokuapp.com", app))
|
||||
d.SetDependencies([]terraform.ResourceDependency{
|
||||
terraform.ResourceDependency{ID: app},
|
||||
})
|
||||
|
||||
log.Printf("[INFO] Domain ID: %s", d.Id())
|
||||
return nil
|
||||
|
|
|
@ -37,12 +37,12 @@ func TestAccHerokuDomain_Basic(t *testing.T) {
|
|||
func testAccCheckHerokuDomainDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*heroku.Service)
|
||||
|
||||
for _, rs := range s.Resources {
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "heroku_domain" {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := client.DomainInfo(rs.Attributes["app"], rs.ID)
|
||||
_, err := client.DomainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
|
||||
|
||||
if err == nil {
|
||||
return fmt.Errorf("Domain still exists")
|
||||
|
@ -65,25 +65,25 @@ func testAccCheckHerokuDomainAttributes(Domain *heroku.Domain) resource.TestChec
|
|||
|
||||
func testAccCheckHerokuDomainExists(n string, Domain *heroku.Domain) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.Resources[n]
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
}
|
||||
|
||||
if rs.ID == "" {
|
||||
if rs.Primary.ID == "" {
|
||||
return fmt.Errorf("No Domain ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*heroku.Service)
|
||||
|
||||
foundDomain, err := client.DomainInfo(rs.Attributes["app"], rs.ID)
|
||||
foundDomain, err := client.DomainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if foundDomain.ID != rs.ID {
|
||||
if foundDomain.ID != rs.Primary.ID {
|
||||
return fmt.Errorf("Domain not found")
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
|
||||
"github.com/cyberdelia/heroku-go/v3"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func resourceHerokuDrain() *schema.Resource {
|
||||
|
@ -52,9 +51,6 @@ func resourceHerokuDrainCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
d.SetId(dr.ID)
|
||||
d.Set("url", dr.URL)
|
||||
d.Set("token", dr.Token)
|
||||
d.SetDependencies([]terraform.ResourceDependency{
|
||||
terraform.ResourceDependency{ID: app},
|
||||
})
|
||||
|
||||
log.Printf("[INFO] Drain ID: %s", d.Id())
|
||||
return nil
|
||||
|
|
|
@ -35,12 +35,12 @@ func TestAccHerokuDrain_Basic(t *testing.T) {
|
|||
func testAccCheckHerokuDrainDestroy(s *terraform.State) error {
|
||||
client := testAccProvider.Meta().(*heroku.Service)
|
||||
|
||||
for _, rs := range s.Resources {
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "heroku_drain" {
|
||||
continue
|
||||
}
|
||||
|
||||
_, err := client.LogDrainInfo(rs.Attributes["app"], rs.ID)
|
||||
_, err := client.LogDrainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
|
||||
|
||||
if err == nil {
|
||||
return fmt.Errorf("Drain still exists")
|
||||
|
@ -67,25 +67,25 @@ func testAccCheckHerokuDrainAttributes(Drain *heroku.LogDrain) resource.TestChec
|
|||
|
||||
func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrain) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.Resources[n]
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
}
|
||||
|
||||
if rs.ID == "" {
|
||||
if rs.Primary.ID == "" {
|
||||
return fmt.Errorf("No Drain ID is set")
|
||||
}
|
||||
|
||||
client := testAccProvider.Meta().(*heroku.Service)
|
||||
|
||||
foundDrain, err := client.LogDrainInfo(rs.Attributes["app"], rs.ID)
|
||||
foundDrain, err := client.LogDrainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if foundDrain.ID != rs.ID {
|
||||
if foundDrain.ID != rs.Primary.ID {
|
||||
return fmt.Errorf("Drain not found")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue