Skip to content

Commit

Permalink
pubsub: fix permadiff with configuring an empty retry_policy. (Google…
Browse files Browse the repository at this point in the history
  • Loading branch information
anavada authored and niharika-98 committed Oct 10, 2024
1 parent 5b26208 commit e3e8db7
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.
2 changes: 2 additions & 0 deletions mmv1/products/pubsub/Subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ properties:
A duration in seconds with up to nine fractional digits, terminated by 's'. Example: "3.5s".
default_from_api: true
diff_suppress_func: 'tpgresource.DurationDiffSuppress'
send_empty_value: true
allow_empty_object: true
- name: 'enableMessageOrdering'
type: Boolean
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ func TestAccPubsubSubscription_emptyTTL(t *testing.T) {
})
}

func TestAccPubsubSubscription_emptyRetryPolicy(t *testing.T) {
t.Parallel()

topic := fmt.Sprintf("tf-test-topic-%s", acctest.RandString(t, 10))
subscription := fmt.Sprintf("tf-test-sub-%s", acctest.RandString(t, 10))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckPubsubSubscriptionDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccPubsubSubscription_emptyRetryPolicy(topic, subscription),
},
{
ResourceName: "google_pubsub_subscription.foo",
ImportStateId: subscription,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccPubsubSubscription_basic(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -494,6 +518,22 @@ resource "google_pubsub_subscription" "foo" {
`, topic, subscription)
}

func testAccPubsubSubscription_emptyRetryPolicy(topic, subscription string) string {
return fmt.Sprintf(`
resource "google_pubsub_topic" "foo" {
name = "%s"
}
resource "google_pubsub_subscription" "foo" {
name = "%s"
topic = google_pubsub_topic.foo.id
retry_policy {
}
}
`, topic, subscription)
}

func testAccPubsubSubscription_push(topicFoo, saAccount, subscription string) string {
return fmt.Sprintf(`
data "google_project" "project" { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
"pushConfig": {
"pushEndpoint": "https://example.com/push"
},
"retryPolicy": null,
"topic": "projects/{{.Provider.project}}/topics/example-pubsub-topic"
}
}
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"pushConfig": {
"pushEndpoint": "https://example.com/push"
},
"retryPolicy": null,
"topic": "projects/{{.Provider.project}}/topics/example-pubsub-topic"
}
},
Expand All @@ -34,4 +35,4 @@
]
}
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"pushConfig": {
"pushEndpoint": "https://example.com/push"
},
"retryPolicy": null,
"topic": "projects/{{.Provider.project}}/topics/example-pubsub-topic"
}
},
Expand All @@ -34,4 +35,4 @@
]
}
}
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"pushConfig": {
"pushEndpoint": "https://example.com/push"
},
"retryPolicy": null,
"topic": "projects/{{.Provider.project}}/topics/example-pubsub-topic"
}
},
Expand All @@ -34,4 +35,4 @@
]
}
}
]
]

0 comments on commit e3e8db7

Please sign in to comment.