providers/heroku: tests passing, compiling

This commit is contained in:
Mitchell Hashimoto 2014-09-16 17:20:47 -07:00
parent 4a736b0dac
commit 64bc356f97
7 changed files with 24 additions and 36 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/cyberdelia/heroku-go/v3" "github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
) )
// Global lock to prevent parallelism for heroku_addon since // 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("plan", plan)
d.Set("provider_id", addon.ProviderID) d.Set("provider_id", addon.ProviderID)
d.Set("config_vars", []interface{}{addon.ConfigVars}) d.Set("config_vars", []interface{}{addon.ConfigVars})
d.SetDependencies([]terraform.ResourceDependency{
terraform.ResourceDependency{ID: d.Get("app").(string)},
})
return nil return nil
} }

View File

@ -72,12 +72,12 @@ func TestAccHerokuAddon_noPlan(t *testing.T) {
func testAccCheckHerokuAddonDestroy(s *terraform.State) error { func testAccCheckHerokuAddonDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Service) client := testAccProvider.Meta().(*heroku.Service)
for _, rs := range s.Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "heroku_addon" { if rs.Type != "heroku_addon" {
continue continue
} }
_, err := client.AddonInfo(rs.Attributes["app"], rs.ID) _, err := client.AddonInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
if err == nil { if err == nil {
return fmt.Errorf("Addon still exists") 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 { func testAccCheckHerokuAddonExists(n string, addon *heroku.Addon) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.Resources[n] rs, ok := s.RootModule().Resources[n]
if !ok { if !ok {
return fmt.Errorf("Not found: %s", n) return fmt.Errorf("Not found: %s", n)
} }
if rs.ID == "" { if rs.Primary.ID == "" {
return fmt.Errorf("No Addon ID is set") return fmt.Errorf("No Addon ID is set")
} }
client := testAccProvider.Meta().(*heroku.Service) 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 { if err != nil {
return err return err
} }
if foundAddon.ID != rs.ID { if foundAddon.ID != rs.Primary.ID {
return fmt.Errorf("Addon not found") return fmt.Errorf("Addon not found")
} }

View File

@ -105,12 +105,12 @@ func TestAccHerokuApp_NukeVars(t *testing.T) {
func testAccCheckHerokuAppDestroy(s *terraform.State) error { func testAccCheckHerokuAppDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Service) client := testAccProvider.Meta().(*heroku.Service)
for _, rs := range s.Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "heroku_app" { if rs.Type != "heroku_app" {
continue continue
} }
_, err := client.AppInfo(rs.ID) _, err := client.AppInfo(rs.Primary.ID)
if err == nil { if err == nil {
return fmt.Errorf("App still exists") 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 { func testAccCheckHerokuAppExists(n string, app *heroku.App) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.Resources[n] rs, ok := s.RootModule().Resources[n]
if !ok { if !ok {
return fmt.Errorf("Not found: %s", n) return fmt.Errorf("Not found: %s", n)
} }
if rs.ID == "" { if rs.Primary.ID == "" {
return fmt.Errorf("No App Name is set") return fmt.Errorf("No App Name is set")
} }
client := testAccProvider.Meta().(*heroku.Service) client := testAccProvider.Meta().(*heroku.Service)
foundApp, err := client.AppInfo(rs.ID) foundApp, err := client.AppInfo(rs.Primary.ID)
if err != nil { if err != nil {
return err return err
} }
if foundApp.Name != rs.ID { if foundApp.Name != rs.Primary.ID {
return fmt.Errorf("App not found") return fmt.Errorf("App not found")
} }

View File

@ -6,7 +6,6 @@ import (
"github.com/cyberdelia/heroku-go/v3" "github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
) )
func resourceHerokuDomain() *schema.Resource { func resourceHerokuDomain() *schema.Resource {
@ -52,9 +51,6 @@ func resourceHerokuDomainCreate(d *schema.ResourceData, meta interface{}) error
d.SetId(do.ID) d.SetId(do.ID)
d.Set("hostname", do.Hostname) d.Set("hostname", do.Hostname)
d.Set("cname", fmt.Sprintf("%s.herokuapp.com", app)) 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()) log.Printf("[INFO] Domain ID: %s", d.Id())
return nil return nil

View File

@ -37,12 +37,12 @@ func TestAccHerokuDomain_Basic(t *testing.T) {
func testAccCheckHerokuDomainDestroy(s *terraform.State) error { func testAccCheckHerokuDomainDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Service) client := testAccProvider.Meta().(*heroku.Service)
for _, rs := range s.Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "heroku_domain" { if rs.Type != "heroku_domain" {
continue continue
} }
_, err := client.DomainInfo(rs.Attributes["app"], rs.ID) _, err := client.DomainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
if err == nil { if err == nil {
return fmt.Errorf("Domain still exists") 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 { func testAccCheckHerokuDomainExists(n string, Domain *heroku.Domain) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.Resources[n] rs, ok := s.RootModule().Resources[n]
if !ok { if !ok {
return fmt.Errorf("Not found: %s", n) return fmt.Errorf("Not found: %s", n)
} }
if rs.ID == "" { if rs.Primary.ID == "" {
return fmt.Errorf("No Domain ID is set") return fmt.Errorf("No Domain ID is set")
} }
client := testAccProvider.Meta().(*heroku.Service) 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 { if err != nil {
return err return err
} }
if foundDomain.ID != rs.ID { if foundDomain.ID != rs.Primary.ID {
return fmt.Errorf("Domain not found") return fmt.Errorf("Domain not found")
} }

View File

@ -6,7 +6,6 @@ import (
"github.com/cyberdelia/heroku-go/v3" "github.com/cyberdelia/heroku-go/v3"
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
) )
func resourceHerokuDrain() *schema.Resource { func resourceHerokuDrain() *schema.Resource {
@ -52,9 +51,6 @@ func resourceHerokuDrainCreate(d *schema.ResourceData, meta interface{}) error {
d.SetId(dr.ID) d.SetId(dr.ID)
d.Set("url", dr.URL) d.Set("url", dr.URL)
d.Set("token", dr.Token) d.Set("token", dr.Token)
d.SetDependencies([]terraform.ResourceDependency{
terraform.ResourceDependency{ID: app},
})
log.Printf("[INFO] Drain ID: %s", d.Id()) log.Printf("[INFO] Drain ID: %s", d.Id())
return nil return nil

View File

@ -35,12 +35,12 @@ func TestAccHerokuDrain_Basic(t *testing.T) {
func testAccCheckHerokuDrainDestroy(s *terraform.State) error { func testAccCheckHerokuDrainDestroy(s *terraform.State) error {
client := testAccProvider.Meta().(*heroku.Service) client := testAccProvider.Meta().(*heroku.Service)
for _, rs := range s.Resources { for _, rs := range s.RootModule().Resources {
if rs.Type != "heroku_drain" { if rs.Type != "heroku_drain" {
continue continue
} }
_, err := client.LogDrainInfo(rs.Attributes["app"], rs.ID) _, err := client.LogDrainInfo(rs.Primary.Attributes["app"], rs.Primary.ID)
if err == nil { if err == nil {
return fmt.Errorf("Drain still exists") 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 { func testAccCheckHerokuDrainExists(n string, Drain *heroku.LogDrain) resource.TestCheckFunc {
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.Resources[n] rs, ok := s.RootModule().Resources[n]
if !ok { if !ok {
return fmt.Errorf("Not found: %s", n) return fmt.Errorf("Not found: %s", n)
} }
if rs.ID == "" { if rs.Primary.ID == "" {
return fmt.Errorf("No Drain ID is set") return fmt.Errorf("No Drain ID is set")
} }
client := testAccProvider.Meta().(*heroku.Service) 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 { if err != nil {
return err return err
} }
if foundDrain.ID != rs.ID { if foundDrain.ID != rs.Primary.ID {
return fmt.Errorf("Drain not found") return fmt.Errorf("Drain not found")
} }