|
| 1 | +// Copyright (c) HashiCorp, Inc. |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | +// ---------------------------------------------------------------------------- |
| 4 | +// |
| 5 | +// *** AUTO GENERATED CODE *** Type: Handwritten *** |
| 6 | +// |
| 7 | +// ---------------------------------------------------------------------------- |
| 8 | +// |
| 9 | +// This code is generated by Magic Modules using the following: |
| 10 | +// |
| 11 | +// Source file: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform/services/ces/ces_example_test.go |
| 12 | +// |
| 13 | +// DO NOT EDIT this file directly. Any changes made to this file will be |
| 14 | +// overwritten during the next generation cycle. |
| 15 | +// |
| 16 | +// ---------------------------------------------------------------------------- |
| 17 | +package ces_test |
| 18 | + |
| 19 | +import ( |
| 20 | + "testing" |
| 21 | + |
| 22 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 23 | + "github.com/hashicorp/terraform-plugin-testing/plancheck" |
| 24 | + "github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest" |
| 25 | +) |
| 26 | + |
| 27 | +func TestAccCESExample_update(t *testing.T) { |
| 28 | + t.Parallel() |
| 29 | + |
| 30 | + context := map[string]interface{}{ |
| 31 | + "random_suffix": acctest.RandString(t, 10), |
| 32 | + } |
| 33 | + |
| 34 | + acctest.VcrTest(t, resource.TestCase{ |
| 35 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 36 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 37 | + CheckDestroy: testAccCheckCESExampleDestroyProducer(t), |
| 38 | + Steps: []resource.TestStep{ |
| 39 | + { |
| 40 | + Config: testAccCESExample_cesExampleBasicExample_full(context), |
| 41 | + }, |
| 42 | + { |
| 43 | + ResourceName: "google_ces_example.my-example", |
| 44 | + ImportState: true, |
| 45 | + ImportStateVerify: true, |
| 46 | + ImportStateVerifyIgnore: []string{"app", "example_id", "location"}, |
| 47 | + }, |
| 48 | + { |
| 49 | + Config: testAccCESExample_cesExampleBasicExample_update(context), |
| 50 | + ConfigPlanChecks: resource.ConfigPlanChecks{ |
| 51 | + PreApply: []plancheck.PlanCheck{ |
| 52 | + plancheck.ExpectResourceAction("google_ces_example.my-example", plancheck.ResourceActionUpdate), |
| 53 | + }, |
| 54 | + }, |
| 55 | + }, |
| 56 | + { |
| 57 | + ResourceName: "google_ces_example.my-example", |
| 58 | + ImportState: true, |
| 59 | + ImportStateVerify: true, |
| 60 | + ImportStateVerifyIgnore: []string{"app", "example_id", "location"}, |
| 61 | + }, |
| 62 | + }, |
| 63 | + }) |
| 64 | +} |
| 65 | + |
| 66 | +func testAccCESExample_cesExampleBasicExample_full(context map[string]interface{}) string { |
| 67 | + return acctest.Nprintf(` |
| 68 | +resource "google_ces_app" "my-app" { |
| 69 | + location = "us" |
| 70 | + display_name = "tf-test-my-app%{random_suffix}" |
| 71 | + app_id = "tf-test-app-id%{random_suffix}" |
| 72 | + time_zone_settings { |
| 73 | + time_zone = "America/Los_Angeles" |
| 74 | + } |
| 75 | +} |
| 76 | +resource "google_ces_example" "my-example" { |
| 77 | + location = "us" |
| 78 | + display_name = "tf-test-my-example%{random_suffix}" |
| 79 | + app = google_ces_app.my-app.name |
| 80 | + example_id = "tf-test-example-id%{random_suffix}" |
| 81 | + description = "example description" |
| 82 | + messages { |
| 83 | + chunks { |
| 84 | + image { |
| 85 | + mime_type = "image/png" |
| 86 | + data = base64encode("This is some fake image binary data.") |
| 87 | + } |
| 88 | + } |
| 89 | + chunks { |
| 90 | + text = "text_data" |
| 91 | + } |
| 92 | + chunks { |
| 93 | + updated_variables = jsonencode({ |
| 94 | + var1 = "val1" |
| 95 | + var2 = "val2" |
| 96 | + }) |
| 97 | + } |
| 98 | + role = "agent" |
| 99 | + } |
| 100 | +} |
| 101 | +`, context) |
| 102 | +} |
| 103 | + |
| 104 | +func testAccCESExample_cesExampleBasicExample_update(context map[string]interface{}) string { |
| 105 | + return acctest.Nprintf(` |
| 106 | +resource "google_ces_app" "my-app" { |
| 107 | + location = "us" |
| 108 | + display_name = "tf-test-my-app%{random_suffix}" |
| 109 | + app_id = "tf-test-app-id%{random_suffix}" |
| 110 | + time_zone_settings { |
| 111 | + time_zone = "America/Los_Angeles" |
| 112 | + } |
| 113 | +} |
| 114 | +resource "google_ces_example" "my-example" { |
| 115 | + location = "us" |
| 116 | + display_name = "tf-test-my-example%{random_suffix}" |
| 117 | + app = google_ces_app.my-app.name |
| 118 | + example_id = "tf-test-example-id%{random_suffix}" |
| 119 | + description = "updated description" |
| 120 | + messages { |
| 121 | + chunks { |
| 122 | + image { |
| 123 | + mime_type = "image/png" |
| 124 | + data = base64encode("This is some fake image binary data.") |
| 125 | + } |
| 126 | + } |
| 127 | + chunks { |
| 128 | + text = "text_data_updated" |
| 129 | + } |
| 130 | + chunks { |
| 131 | + updated_variables = jsonencode({ |
| 132 | + var1 = "val1_updated" |
| 133 | + var2 = "val2_updated" |
| 134 | + }) |
| 135 | + } |
| 136 | + role = "agent" |
| 137 | + } |
| 138 | +} |
| 139 | +`, context) |
| 140 | +} |
0 commit comments