mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-10-04 17:51:11 +00:00
30fe927df6
<!-- This change is generated by MagicModules. --> /cc @kierachell
42 lines
956 B
Go
42 lines
956 B
Go
package google
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
)
|
|
|
|
func TestAccDataSourceGoogleKmsKeyRing_basic(t *testing.T) {
|
|
kms := BootstrapKMSKey(t)
|
|
|
|
keyParts := strings.Split(kms.KeyRing.Name, "/")
|
|
keyRingId := keyParts[len(keyParts)-1]
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
Providers: testAccProviders,
|
|
Steps: []resource.TestStep{
|
|
{
|
|
Config: testAccDataSourceGoogleKmsKeyRing_basic(keyRingId),
|
|
Check: resource.TestMatchResourceAttr("data.google_kms_key_ring.kms_key_ring", "self_link", regexp.MustCompile(kms.KeyRing.Name)),
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
/*
|
|
This test should run in its own project, because keys and key rings are not deletable
|
|
*/
|
|
func testAccDataSourceGoogleKmsKeyRing_basic(keyRingName string) string {
|
|
return fmt.Sprintf(`
|
|
|
|
data "google_kms_key_ring" "kms_key_ring" {
|
|
name = "%s"
|
|
location = "global"
|
|
}
|
|
`, keyRingName)
|
|
}
|