Skip to content

Commit

Permalink
add filter key to pubsub subscription unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-codes committed Jul 22, 2020
1 parent 2a4bc37 commit 5265ede
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions third_party/terraform/tests/resource_pubsub_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAccPubsubSubscription_basic(t *testing.T) {
CheckDestroy: testAccCheckPubsubSubscriptionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccPubsubSubscription_basic(topic, subscription, "bar", 20),
Config: testAccPubsubSubscription_basic(topic, subscription, "attributes.foo = \"bar\"", "bar", 20),
},
{
ResourceName: "google_pubsub_subscription.foo",
Expand All @@ -69,7 +69,7 @@ func TestAccPubsubSubscription_update(t *testing.T) {
CheckDestroy: testAccCheckPubsubSubscriptionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccPubsubSubscription_basic(topic, subscriptionShort, "bar", 20),
Config: testAccPubsubSubscription_basic(topic, subscriptionShort, "attributes.foo = \"bar\"", "bar", 20),
},
{
ResourceName: "google_pubsub_subscription.foo",
Expand All @@ -78,7 +78,7 @@ func TestAccPubsubSubscription_update(t *testing.T) {
ImportStateVerify: true,
},
{
Config: testAccPubsubSubscription_basic(topic, subscriptionShort, "baz", 30),
Config: testAccPubsubSubscription_basic(topic, subscriptionShort, "attributes.foo = \"bar\"", "baz", 30),
Check: resource.TestCheckResourceAttr(
"google_pubsub_subscription.foo", "path", subscriptionLong,
),
Expand Down Expand Up @@ -212,21 +212,22 @@ resource "google_pubsub_subscription" "foo" {
`, saAccount, topicFoo, subscription)
}

func testAccPubsubSubscription_basic(topic, subscription, label string, deadline int) string {
func testAccPubsubSubscription_basic(topic, subscription, filter string, label string, deadline int) string {
return fmt.Sprintf(`
resource "google_pubsub_topic" "foo" {
name = "%s"
}
resource "google_pubsub_subscription" "foo" {
name = "%s"
topic = google_pubsub_topic.foo.id
name = "%s"
topic = google_pubsub_topic.foo.id
filter = "%s"
labels = {
foo = "%s"
}
ack_deadline_seconds = %d
}
`, topic, subscription, label, deadline)
`, topic, subscription, filter, label, deadline)
}

func testAccPubsubSubscription_topicOnly(topic string) string {
Expand Down

0 comments on commit 5265ede

Please sign in to comment.