forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed pubsublite update issues (GoogleCloudPlatform#4954)
* fixed pubsublite update issues * add tests
- Loading branch information
1 parent
2600331
commit 6f1163c
Showing
3 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
mmv1/third_party/terraform/tests/resource_pubsub_lite_subscription_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccPubsubLiteSubscription_pubsubLiteSubscription_deliveryRequirement_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
topic := fmt.Sprintf("tf-test-topic-foo-%s", randString(t, 10)) | ||
subscription := fmt.Sprintf("tf-test-topic-foo-%s", randString(t, 10)) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckPubsubLiteSubscriptionDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccPubsubLiteSubscription_pubsubLiteSubscription_deliveryRequirement_update(topic, subscription, "DELIVER_AFTER_STORED"), | ||
}, | ||
{ | ||
ResourceName: "google_pubsub_lite_subscription.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"topic", "region", "zone", "name"}, | ||
}, | ||
{ | ||
Config: testAccPubsubLiteSubscription_pubsubLiteSubscription_deliveryRequirement_update(topic, subscription, "DELIVER_IMMEDIATELY"), | ||
}, | ||
{ | ||
ResourceName: "google_pubsub_lite_subscription.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"topic", "region", "zone", "name"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccPubsubLiteSubscription_pubsubLiteSubscription_deliveryRequirement_update(topic, subscription, delivery string) string { | ||
return fmt.Sprintf(` | ||
resource "google_pubsub_lite_topic" "example" { | ||
name = "%s" | ||
partition_config { | ||
count = 1 | ||
capacity { | ||
publish_mib_per_sec = 4 | ||
subscribe_mib_per_sec = 8 | ||
} | ||
} | ||
retention_config { | ||
per_partition_bytes = 32212254720 | ||
} | ||
} | ||
resource "google_pubsub_lite_subscription" "example" { | ||
name = "%s" | ||
topic = google_pubsub_lite_topic.example.name | ||
delivery_config { | ||
delivery_requirement = "%s" | ||
} | ||
} | ||
`, topic, subscription, delivery) | ||
} |
60 changes: 60 additions & 0 deletions
60
mmv1/third_party/terraform/tests/resource_pubsub_lite_topic_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccPubsubLiteTopic_pubsubLiteTopic_count_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
topic := fmt.Sprintf("tf-test-topic-foo-%s", randString(t, 10)) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckPubsubLiteTopicDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccPubsubLiteTopic_pubsubLiteTopic_count_update(topic, "1"), | ||
}, | ||
{ | ||
ResourceName: "google_pubsub_lite_topic.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"region", "zone", "name"}, | ||
}, | ||
{ | ||
Config: testAccPubsubLiteTopic_pubsubLiteTopic_count_update(topic, "2"), | ||
}, | ||
{ | ||
ResourceName: "google_pubsub_lite_topic.example", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"region", "zone", "name"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccPubsubLiteTopic_pubsubLiteTopic_count_update(topic, count string) string { | ||
return fmt.Sprintf(` | ||
resource "google_pubsub_lite_topic" "example" { | ||
name = "%s" | ||
partition_config { | ||
count = %s | ||
capacity { | ||
publish_mib_per_sec = 4 | ||
subscribe_mib_per_sec = 8 | ||
} | ||
} | ||
retention_config { | ||
per_partition_bytes = 32212254720 | ||
} | ||
} | ||
`, topic, count) | ||
} |