|
| 1 | +package gemini_test |
| 2 | +{{- if ne $.TargetVersionName "ga" }} |
| 3 | + |
| 4 | +import ( |
| 5 | + "fmt" |
| 6 | + "testing" |
| 7 | + |
| 8 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 9 | + "github.com/hashicorp/terraform-plugin-testing/plancheck" |
| 10 | + |
| 11 | + "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 12 | +) |
| 13 | + |
| 14 | +func TestAccGeminiDataSharingWithGoogleSettingBinding_update(t *testing.T) { |
| 15 | + t.Parallel() |
| 16 | + |
| 17 | + context := map[string]interface{}{ |
| 18 | + "data_sharing_with_google_setting_id": fmt.Sprintf("tf-test-ls-%s", acctest.RandString(t, 10)), |
| 19 | + "setting_binding_id": fmt.Sprintf("tf-test-lsb-%s", acctest.RandString(t, 10)), |
| 20 | + } |
| 21 | + |
| 22 | + acctest.VcrTest(t, resource.TestCase{ |
| 23 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 24 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t), |
| 25 | + Steps: []resource.TestStep{ |
| 26 | + { |
| 27 | + Config: testAccGeminiDataSharingWithGoogleSettingBinding_basic(context), |
| 28 | + }, |
| 29 | + { |
| 30 | + ResourceName: "google_gemini_data_sharing_with_google_setting_binding.basic_binding", |
| 31 | + ImportState: true, |
| 32 | + ImportStateVerify: true, |
| 33 | + ImportStateVerifyIgnore: []string{"labels", "location", "data_sharing_with_google_setting_id", "terraform_labels"}, |
| 34 | + }, |
| 35 | + { |
| 36 | + Config: testAccGeminiDataSharingWithGoogleSettingBinding_update(context), |
| 37 | + ConfigPlanChecks: resource.ConfigPlanChecks{ |
| 38 | + PreApply: []plancheck.PlanCheck{ |
| 39 | + plancheck.ExpectResourceAction("google_gemini_data_sharing_with_google_setting_binding.basic_binding", plancheck.ResourceActionUpdate), |
| 40 | + }, |
| 41 | + }, |
| 42 | + }, |
| 43 | + { |
| 44 | + ResourceName: "google_gemini_data_sharing_with_google_setting_binding.basic_binding", |
| 45 | + ImportState: true, |
| 46 | + ImportStateVerify: true, |
| 47 | + ImportStateVerifyIgnore: []string{"labels", "location", "data_sharing_with_google_setting_id", "terraform_labels"}, |
| 48 | + }, |
| 49 | + }, |
| 50 | + }) |
| 51 | +} |
| 52 | + |
| 53 | +func testAccGeminiDataSharingWithGoogleSettingBinding_basic(context map[string]interface{}) string { |
| 54 | + return acctest.Nprintf(` |
| 55 | +data "google_project" "project" { |
| 56 | + provider = google-beta |
| 57 | +} |
| 58 | + |
| 59 | +resource "google_gemini_data_sharing_with_google_setting" "basic" { |
| 60 | + provider = google-beta |
| 61 | + data_sharing_with_google_setting_id = "%{data_sharing_with_google_setting_id}" |
| 62 | + location = "global" |
| 63 | + labels = {"my_key" = "my_value"} |
| 64 | + enable_preview_data_sharing = true |
| 65 | +} |
| 66 | + |
| 67 | +resource "google_gemini_data_sharing_with_google_setting_binding" "basic_binding" { |
| 68 | + provider = google-beta |
| 69 | + data_sharing_with_google_setting_id = google_gemini_data_sharing_with_google_setting.basic.data_sharing_with_google_setting_id |
| 70 | + setting_binding_id = "%{setting_binding_id}" |
| 71 | + location = "global" |
| 72 | + target = "projects/${data.google_project.project.number}" |
| 73 | +} |
| 74 | +`, context) |
| 75 | +} |
| 76 | + |
| 77 | +func testAccGeminiDataSharingWithGoogleSettingBinding_update(context map[string]interface{}) string { |
| 78 | + return acctest.Nprintf(` |
| 79 | +data "google_project" "project" { |
| 80 | + provider = google-beta |
| 81 | +} |
| 82 | + |
| 83 | +resource "google_gemini_data_sharing_with_google_setting" "basic" { |
| 84 | + provider = google-beta |
| 85 | + data_sharing_with_google_setting_id = "%{data_sharing_with_google_setting_id}" |
| 86 | + location = "global" |
| 87 | + labels = {"my_key" = "my_value"} |
| 88 | + enable_preview_data_sharing = true |
| 89 | +} |
| 90 | + |
| 91 | +resource "google_gemini_data_sharing_with_google_setting_binding" "basic_binding" { |
| 92 | + provider = google-beta |
| 93 | + data_sharing_with_google_setting_id = google_gemini_data_sharing_with_google_setting.basic.data_sharing_with_google_setting_id |
| 94 | + setting_binding_id = "%{setting_binding_id}" |
| 95 | + location = "global" |
| 96 | + target = "projects/${data.google_project.project.number}" |
| 97 | + labels = {"my_key" = "my_value"} |
| 98 | + product = "GEMINI_CODE_ASSIST" |
| 99 | +} |
| 100 | +`, context) |
| 101 | +} |
| 102 | +{{ end }} |
0 commit comments