mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-04 17:51:11 +00:00
9fbfce3add
Conflicts: builtin/providers/google/provider.go builtin/providers/google/resource_subscription.go builtin/providers/google/resource_subscription_test.go golang pubsub SDK has been released. moved topics/subscriptions to use that Conflicts: builtin/providers/google/provider.go builtin/providers/google/resource_subscription.go builtin/providers/google/resource_subscription_test.go file renames and add documentation files remove typo'd merge and type file move add to index page as well only need to define that once remove topic_computed schema value I think this was used at one point but is no longer. away. cleanup typo adds a couple more config values - ackDeadlineSeconds: number of seconds to wait for an ack - pushAttributes: attributes of a push subscription - pushEndpoint: target for a push subscription rearrange to better match current conventions respond to all of the comments
75 lines
1.7 KiB
Go
75 lines
1.7 KiB
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
)
|
|
|
|
func TestAccPubsubSubscriptionCreate(t *testing.T) {
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
CheckDestroy: testAccCheckPubsubSubscriptionDestroy,
|
|
Steps: []resource.TestStep{
|
|
resource.TestStep{
|
|
Config: testAccPubsubSubscription,
|
|
Check: resource.ComposeTestCheckFunc(
|
|
testAccPubsubSubscriptionExists(
|
|
"google_pubsub_subscription.foobar_sub"),
|
|
),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
func testAccCheckPubsubSubscriptionDestroy(s *terraform.State) error {
|
|
for _, rs := range s.RootModule().Resources {
|
|
if rs.Type != "google_pubsub_subscription" {
|
|
continue
|
|
}
|
|
|
|
config := testAccProvider.Meta().(*Config)
|
|
_, err := config.clientPubsub.Projects.Subscriptions.Get(rs.Primary.ID).Do()
|
|
if err != nil {
|
|
fmt.Errorf("Subscription still present")
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func testAccPubsubSubscriptionExists(n string) resource.TestCheckFunc {
|
|
return func(s *terraform.State) error {
|
|
rs, ok := s.RootModule().Resources[n]
|
|
if !ok {
|
|
return fmt.Errorf("Not found: %s", n)
|
|
}
|
|
|
|
if rs.Primary.ID == "" {
|
|
return fmt.Errorf("No ID is set")
|
|
}
|
|
config := testAccProvider.Meta().(*Config)
|
|
_, err := config.clientPubsub.Projects.Subscriptions.Get(rs.Primary.ID).Do()
|
|
if err != nil {
|
|
fmt.Errorf("Subscription still present")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
}
|
|
|
|
const testAccPubsubSubscription = `
|
|
resource "google_pubsub_topic" "foobar_sub" {
|
|
name = "foobar_sub"
|
|
}
|
|
|
|
resource "google_pubsub_subscription" "foobar_sub" {
|
|
name = "foobar_sub"
|
|
topic = "${google_pubsub_topic.foobar_sub.name}"
|
|
}`
|
|
|