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 TestAccGeminiLoggingSettingBinding_update(t *testing.T) {
15
+ t.Parallel()
16
+
17
+ context := map[string]interface{}{
18
+ "logging_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: testAccGeminiLoggingSettingBinding_basic(context),
28
+ },
29
+ {
30
+ ResourceName: "google_gemini_logging_setting_binding.basic_binding",
31
+ ImportState: true,
32
+ ImportStateVerify: true,
33
+ ImportStateVerifyIgnore: []string{"labels", "location", "logging_setting_id", "terraform_labels"},
34
+ },
35
+ {
36
+ Config: testAccGeminiLoggingSettingBinding_update(context),
37
+ ConfigPlanChecks: resource.ConfigPlanChecks{
38
+ PreApply: []plancheck.PlanCheck{
39
+ plancheck.ExpectResourceAction("google_gemini_logging_setting_binding.basic_binding", plancheck.ResourceActionUpdate),
40
+ },
41
+ },
42
+ },
43
+ {
44
+ ResourceName: "google_gemini_logging_setting_binding.basic_binding",
45
+ ImportState: true,
46
+ ImportStateVerify: true,
47
+ ImportStateVerifyIgnore: []string{"labels", "location", "logging_setting_id", "terraform_labels"},
48
+ },
49
+ },
50
+ })
51
+ }
52
+
53
+ func testAccGeminiLoggingSettingBinding_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_logging_setting" "basic" {
60
+ provider = google-beta
61
+ logging_setting_id = "%{logging_setting_id}"
62
+ location = "global"
63
+ labels = {"my_key" = "my_value"}
64
+ log_prompts_and_responses = true
65
+ }
66
+
67
+ resource "google_gemini_logging_setting_binding" "basic_binding" {
68
+ provider = google-beta
69
+ logging_setting_id = google_gemini_logging_setting.basic.logging_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 testAccGeminiLoggingSettingBinding_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_logging_setting" "basic" {
84
+ provider = google-beta
85
+ logging_setting_id = "%{logging_setting_id}"
86
+ location = "global"
87
+ labels = {"my_key" = "my_value"}
88
+ log_prompts_and_responses = true
89
+ }
90
+
91
+ resource "google_gemini_logging_setting_binding" "basic_binding" {
92
+ provider = google-beta
93
+ logging_setting_id = google_gemini_logging_setting.basic.logging_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