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.
Firebase hosting channel (GoogleCloudPlatform#6791)
* Firebase Hosting Channels * Use references site_id * Add handwritten update test * Use billing_project instead of project * Remove dependence on a project
- Loading branch information
1 parent
8822c02
commit 980757c
Showing
5 changed files
with
316 additions
and
1 deletion.
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
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
11 changes: 11 additions & 0 deletions
11
mmv1/templates/terraform/examples/firebasehosting_channel_basic.tf.erb
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,11 @@ | ||
resource "google_firebase_hosting_site" "default" { | ||
provider = google-beta | ||
project = "<%= ctx[:test_env_vars]['project_id'] %>" | ||
site_id = "<%= ctx[:vars]['site_id'] %>" | ||
} | ||
|
||
resource "google_firebase_hosting_channel" "default" { | ||
provider = google-beta | ||
site_id = google_firebase_hosting_site.default.site_id | ||
channel_id = "<%= ctx[:vars]['channel_id'] %>" | ||
} |
16 changes: 16 additions & 0 deletions
16
mmv1/templates/terraform/examples/firebasehosting_channel_full.tf.erb
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,16 @@ | ||
resource "google_firebase_hosting_site" "default" { | ||
provider = google-beta | ||
project = "<%= ctx[:test_env_vars]['project_id'] %>" | ||
site_id = "<%= ctx[:vars]['site_id'] %>" | ||
} | ||
|
||
resource "google_firebase_hosting_channel" "full" { | ||
provider = google-beta | ||
site_id = google_firebase_hosting_site.default.site_id | ||
channel_id = "<%= ctx[:vars]['channel_id'] %>" | ||
ttl = "86400s" | ||
retained_release_count = 20 | ||
labels = { | ||
"some-key": "some-value" | ||
} | ||
} |
195 changes: 195 additions & 0 deletions
195
mmv1/third_party/terraform/tests/resource_firebase_hosting_channel_test.go.erb
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,195 @@ | ||
<% autogen_exception -%> | ||
package google | ||
<% unless version == 'ga' -%> | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccFirebaseHostingChannel_firebasehostingChannelUpdate(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"project_id": getTestProjectFromEnv(), | ||
"random_suffix": randString(t, 10), | ||
} | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProvidersOiCS, | ||
CheckDestroy: testAccCheckFirebaseHostingChannelDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccFirebaseHostingChannel_firebasehostingChannelBasic(context), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_hosting_channel.update", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"ttl", "site_id", "channel_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseHostingChannel_firebasehostingChannelTtl(context, "8600s"), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_hosting_channel.update", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"ttl", "site_id", "channel_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseHostingChannel_firebasehostingChannelTtl(context, "86400s"), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_hosting_channel.update", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"ttl", "site_id", "channel_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseHostingChannel_firebasehostingChannelRetainedReleaseCount(context, 30), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_hosting_channel.update", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"ttl", "site_id", "channel_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseHostingChannel_firebasehostingChannelRetainedReleaseCount(context, 20), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_hosting_channel.update", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"ttl", "site_id", "channel_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseHostingChannel_firebasehostingChannelLabels(context), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_hosting_channel.update", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"ttl", "site_id", "channel_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseHostingChannel_firebasehostingChannelMultipleFields(context), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_hosting_channel.update", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"ttl", "site_id", "channel_id"}, | ||
}, | ||
{ | ||
Config: testAccFirebaseHostingChannel_firebasehostingChannelBasic(context), | ||
}, | ||
{ | ||
ResourceName: "google_firebase_hosting_channel.update", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"ttl", "site_id", "channel_id"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccFirebaseHostingChannel_firebasehostingChannelBasic(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_firebase_hosting_site" "default" { | ||
provider = google-beta | ||
project = "%{project_id}" | ||
site_id = "tf-test-site-with-channel%{random_suffix}" | ||
} | ||
|
||
resource "google_firebase_hosting_channel" "update" { | ||
provider = google-beta | ||
site_id = google_firebase_hosting_site.default.site_id | ||
channel_id = "tf-test-channel-update%{random_suffix}" | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccFirebaseHostingChannel_firebasehostingChannelTtl(context map[string]interface{}, ttl string) string { | ||
context["ttl"] = ttl | ||
return Nprintf(` | ||
resource "google_firebase_hosting_site" "default" { | ||
provider = google-beta | ||
project = "%{project_id}" | ||
site_id = "tf-test-site-with-channel%{random_suffix}" | ||
} | ||
|
||
resource "google_firebase_hosting_channel" "update" { | ||
provider = google-beta | ||
site_id = google_firebase_hosting_site.default.site_id | ||
channel_id = "tf-test-channel-update%{random_suffix}" | ||
ttl = "%{ttl}" | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccFirebaseHostingChannel_firebasehostingChannelRetainedReleaseCount(context map[string]interface{}, retainedReleaseCount int) string { | ||
context["retained_release_count"] = retainedReleaseCount | ||
return Nprintf(` | ||
resource "google_firebase_hosting_site" "default" { | ||
provider = google-beta | ||
project = "%{project_id}" | ||
site_id = "tf-test-site-with-channel%{random_suffix}" | ||
} | ||
|
||
resource "google_firebase_hosting_channel" "update" { | ||
provider = google-beta | ||
site_id = google_firebase_hosting_site.default.site_id | ||
channel_id = "tf-test-channel-update%{random_suffix}" | ||
ttl = "86400s" | ||
retained_release_count = %{retained_release_count} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccFirebaseHostingChannel_firebasehostingChannelLabels(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_firebase_hosting_site" "default" { | ||
provider = google-beta | ||
project = "%{project_id}" | ||
site_id = "tf-test-site-with-channel%{random_suffix}" | ||
} | ||
|
||
resource "google_firebase_hosting_channel" "update" { | ||
provider = google-beta | ||
site_id = google_firebase_hosting_site.default.site_id | ||
channel_id = "tf-test-channel-update%{random_suffix}" | ||
ttl = "86400s" | ||
retained_release_count = 10 | ||
labels = { | ||
"some-key": "some-value" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccFirebaseHostingChannel_firebasehostingChannelMultipleFields(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_firebase_hosting_site" "default" { | ||
provider = google-beta | ||
project = "%{project_id}" | ||
site_id = "tf-test-site-with-channel%{random_suffix}" | ||
} | ||
|
||
resource "google_firebase_hosting_channel" "update" { | ||
provider = google-beta | ||
site_id = google_firebase_hosting_site.default.site_id | ||
channel_id = "tf-test-channel-update%{random_suffix}" | ||
ttl = "86400s" | ||
retained_release_count = 40 | ||
labels = { | ||
"some-key-2": "some-value-2" | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
<% end -%> |