Add example tests for Redis, Filestore, ContainerAnalysis (#2131)

<!-- This change is generated by MagicModules. -->
/cc @rileykarson
This commit is contained in:
The Magician 2018-10-05 15:28:31 -07:00 committed by Riley Karson
parent b508dfd1cd
commit 1b88724449
8 changed files with 281 additions and 62 deletions

View File

@ -0,0 +1,57 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccContainerAnalysisNote_containerAnalysisNoteBasicExample(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckContainerAnalysisNoteDestroy,
Steps: []resource.TestStep{
{
Config: testAccContainerAnalysisNote_containerAnalysisNoteBasicExample(acctest.RandString(10)),
},
{
ResourceName: "google_container_analysis_note.note",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccContainerAnalysisNote_containerAnalysisNoteBasicExample(val string) string {
return fmt.Sprintf(`
resource "google_container_analysis_note" "note" {
name = "test-attestor-note-%s"
attestation_authority {
hint {
human_readable_name = "Attestor Note"
}
}
}
`, val,
)
}

View File

@ -0,0 +1,65 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccFilestoreInstance_filestoreInstanceBasicExample(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckFilestoreInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccFilestoreInstance_filestoreInstanceBasicExample(acctest.RandString(10)),
},
{
ResourceName: "google_filestore_instance.instance",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"zone"},
},
},
})
}
func testAccFilestoreInstance_filestoreInstanceBasicExample(val string) string {
return fmt.Sprintf(`
resource "google_filestore_instance" "instance" {
name = "test-instance-%s"
zone = "us-central1-b"
tier = "PREMIUM"
file_shares {
capacity_gb = 2660
name = "share1"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
}
}
`, val,
)
}

View File

@ -0,0 +1,104 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccRedisInstance_redisInstanceBasicExample(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRedisInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccRedisInstance_redisInstanceBasicExample(acctest.RandString(10)),
},
{
ResourceName: "google_redis_instance.cache",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"region"},
},
},
})
}
func testAccRedisInstance_redisInstanceBasicExample(val string) string {
return fmt.Sprintf(`
resource "google_redis_instance" "cache" {
name = "memory-cache-%s"
memory_size_gb = 1
}
`, val,
)
}
func TestAccRedisInstance_redisInstanceFullExample(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckRedisInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccRedisInstance_redisInstanceFullExample(acctest.RandString(10)),
},
{
ResourceName: "google_redis_instance.cache",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"region"},
},
},
})
}
func testAccRedisInstance_redisInstanceFullExample(val string) string {
return fmt.Sprintf(`
resource "google_redis_instance" "cache" {
name = "ha-memory-cache-%s"
tier = "STANDARD_HA"
memory_size_gb = 1
location_id = "us-central1-a"
alternative_location_id = "us-central1-f"
authorized_network = "${google_compute_network.auto-network.self_link}"
redis_version = "REDIS_3_2"
display_name = "Terraform Test Instance"
reserved_ip_range = "192.168.0.0/29"
labels {
my_key = "my_val"
other_key = "other_val"
}
}
resource "google_compute_network" "auto-network" {
name = "authorized-network-%s"
}
`, val, val,
)
}

View File

@ -35,15 +35,6 @@ To get more information about Attestor, see:
## Example Usage
```hcl
resource "google_container_analysis_note" "note" {
name = "test-attestor-note"
attestation_authority {
hint {
human_readable_name = "Attestor Note"
}
}
}
resource "google_binary_authorization_attestor" "attestor" {
name = "test-attestor"
attestation_authority_note {
@ -69,6 +60,15 @@ EOF
}
}
}
resource "google_container_analysis_note" "note" {
name = "test-attestor-note"
attestation_authority {
hint {
human_readable_name = "Attestor Note"
}
}
}
```
## Argument Reference

View File

@ -35,22 +35,6 @@ To get more information about Policy, see:
## Example Usage
```hcl
resource "google_container_analysis_note" "note" {
name = "test-attestor-note"
attestation_authority {
hint {
human_readable_name = "My attestor"
}
}
}
resource "google_binary_authorization_attestor" "attestor" {
name = "test-attestor"
attestation_authority_note {
note_reference = "${google_container_analysis_note.note.name}"
}
}
resource "google_binary_authorization_policy" "policy" {
admission_whitelist_patterns {
name_pattern= "gcr.io/google_containers/*"
@ -68,6 +52,22 @@ resource "google_binary_authorization_policy" "policy" {
require_attestations_by = ["${google_binary_authorization_attestor.attestor.name}"]
}
}
resource "google_container_analysis_note" "note" {
name = "test-attestor-note"
attestation_authority {
hint {
human_readable_name = "My attestor"
}
}
}
resource "google_binary_authorization_attestor" "attestor" {
name = "test-attestor"
attestation_authority_note {
note_reference = "${google_container_analysis_note.note.name}"
}
}
```
## Argument Reference

View File

@ -36,21 +36,22 @@ To get more information about Instance, see:
## Example Usage
### Basic Usage
```hcl
resource "google_file_instance" "instance" {
name = "test-instance"
zone = "us-central1-b"
file_shares {
capacity_gb = 2660
name = "share1"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
}
tier = "PREMIUM"
resource "google_filestore_instance" "instance" {
name = "test-instance"
zone = "us-central1-b"
tier = "PREMIUM"
file_shares {
capacity_gb = 2660
name = "share1"
}
networks {
network = "default"
modes = ["MODE_IPV4"]
}
}
```
## Argument Reference

View File

@ -32,30 +32,22 @@ To get more information about Instance, see:
## Example Usage
### Basic Usage
```hcl
resource "google_redis_instance" "test" {
name = "%s"
resource "google_redis_instance" "cache" {
name = "memory-cache"
memory_size_gb = 1
}
```
### Full Usage
```hcl
resource "google_compute_network" "test" {
name = "%s"
}
resource "google_redis_instance" "test" {
name = "%s"
resource "google_redis_instance" "cache" {
name = "ha-memory-cache"
tier = "STANDARD_HA"
memory_size_gb = 1
region = "us-central1"
location_id = "us-central1-a"
alternative_location_id = "us-central1-f"
authorized_network = "${google_compute_network.test.self_link}"
authorized_network = "${google_compute_network.auto-network.self_link}"
redis_version = "REDIS_3_2"
display_name = "Terraform Test Instance"
@ -66,6 +58,10 @@ resource "google_redis_instance" "test" {
other_key = "other_val"
}
}
resource "google_compute_network" "auto-network" {
name = "authorized-network"
}
```
## Argument Reference

View File

@ -28,20 +28,16 @@ A Lien represents an encumbrance on the actions that can be performed on a resou
## Example Usage
```hcl
resource "random_id" "r" {
byte_length = 8
}
resource "google_project" "project" {
project_id = "project-${random_id.r.hex}"
name = "A very important project!"
}
resource "google_resource_manager_lien" "lien" {
parent = "projects/${google_project.project.number}"
restrictions = ["resourcemanager.projects.delete"]
origin = "machine-readable-explanation"
reason = "This project is very important to me!"
reason = "This project is an important environment"
}
resource "google_project" "project" {
project_id = "staging-project"
name = "A very important project!"
}
```