|
| 1 | +package securesourcemanager_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 7 | + "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 8 | +) |
| 9 | + |
| 10 | +func TestAccSecureSourceManagerBranchRule_secureSourceManagerBranchRuleWithFieldsExample_update(t *testing.T) { |
| 11 | + t.Parallel() |
| 12 | + |
| 13 | + context := map[string]interface{}{ |
| 14 | + "prevent_destroy": false, |
| 15 | + "random_suffix": acctest.RandString(t, 10), |
| 16 | + } |
| 17 | + |
| 18 | + acctest.VcrTest(t, resource.TestCase{ |
| 19 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 20 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 21 | + Steps: []resource.TestStep{ |
| 22 | + { |
| 23 | + Config: testAccSecureSourceManagerBranchRule_secureSourceManagerBranchRuleWithFieldsExample_full(context), |
| 24 | + }, |
| 25 | + { |
| 26 | + ResourceName: "google_secure_source_manager_branch_rule.default", |
| 27 | + ImportState: true, |
| 28 | + ImportStateVerify: true, |
| 29 | + ImportStateVerifyIgnore: []string{"branch_rule_id", "location", "repository_id"}, |
| 30 | + }, |
| 31 | + { |
| 32 | + Config: testAccSecureSourceManagerBranchRule_secureSourceManagerBranchRuleWithFieldsExample_update(context), |
| 33 | + }, |
| 34 | + { |
| 35 | + ResourceName: "google_secure_source_manager_branch_rule.default", |
| 36 | + ImportState: true, |
| 37 | + ImportStateVerify: true, |
| 38 | + ImportStateVerifyIgnore: []string{"branch_rule_id", "location", "repository_id"}, |
| 39 | + }, |
| 40 | + }, |
| 41 | + }) |
| 42 | +} |
| 43 | + |
| 44 | +func testAccSecureSourceManagerBranchRule_secureSourceManagerBranchRuleWithFieldsExample_full(context map[string]interface{}) string { |
| 45 | + return acctest.Nprintf(` |
| 46 | +resource "google_secure_source_manager_instance" "instance" { |
| 47 | + location = "us-central1" |
| 48 | + instance_id = "tf-test-my-initial-instance%{random_suffix}" |
| 49 | + # Prevent accidental deletions. |
| 50 | + lifecycle { |
| 51 | + prevent_destroy = "%{prevent_destroy}" |
| 52 | + } |
| 53 | +} |
| 54 | +
|
| 55 | +resource "google_secure_source_manager_repository" "repository" { |
| 56 | + repository_id = "tf-test-my-initial-repository%{random_suffix}" |
| 57 | + instance = google_secure_source_manager_instance.instance.name |
| 58 | + location = google_secure_source_manager_instance.instance.location |
| 59 | + # Prevent accidental deletions. |
| 60 | + lifecycle { |
| 61 | + prevent_destroy = "%{prevent_destroy}" |
| 62 | + } |
| 63 | +} |
| 64 | +
|
| 65 | +resource "google_secure_source_manager_branch_rule" "default" { |
| 66 | + branch_rule_id = "tf-test-my-initial-branchrule%{random_suffix}" |
| 67 | + location = google_secure_source_manager_repository.repository.location |
| 68 | + repository_id = google_secure_source_manager_repository.repository.repository_id |
| 69 | + include_pattern = "test" |
| 70 | + minimum_approvals_count = 2 |
| 71 | + minimum_reviews_count = 2 |
| 72 | + require_comments_resolved = true |
| 73 | + require_linear_history = true |
| 74 | + require_pull_request = true |
| 75 | + disabled = false |
| 76 | + allow_stale_reviews = false |
| 77 | +} |
| 78 | +`, context) |
| 79 | +} |
| 80 | + |
| 81 | +func testAccSecureSourceManagerBranchRule_secureSourceManagerBranchRuleWithFieldsExample_update(context map[string]interface{}) string { |
| 82 | + return acctest.Nprintf(` |
| 83 | +resource "google_secure_source_manager_instance" "instance" { |
| 84 | + location = "us-central1" |
| 85 | + instance_id = "tf-test-my-initial-instance%{random_suffix}" |
| 86 | + # Prevent accidental deletions. |
| 87 | + lifecycle { |
| 88 | + prevent_destroy = "%{prevent_destroy}" |
| 89 | + } |
| 90 | +} |
| 91 | +
|
| 92 | +resource "google_secure_source_manager_repository" "repository" { |
| 93 | + repository_id = "tf-test-my-initial-repository%{random_suffix}" |
| 94 | + instance = google_secure_source_manager_instance.instance.name |
| 95 | + location = google_secure_source_manager_instance.instance.location |
| 96 | + # Prevent accidental deletions. |
| 97 | + lifecycle { |
| 98 | + prevent_destroy = "%{prevent_destroy}" |
| 99 | + } |
| 100 | +} |
| 101 | +
|
| 102 | +resource "google_secure_source_manager_branch_rule" "default" { |
| 103 | + branch_rule_id = "tf-test-my-initial-branchrule%{random_suffix}" |
| 104 | + location = google_secure_source_manager_repository.repository.location |
| 105 | + repository_id = google_secure_source_manager_repository.repository.repository_id |
| 106 | + include_pattern = "test" |
| 107 | + minimum_approvals_count = 1 |
| 108 | + minimum_reviews_count = 1 |
| 109 | + require_linear_history = false |
| 110 | +} |
| 111 | +`, context) |
| 112 | +} |
0 commit comments