mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Corrected test for generating disk from a snapshot URI from another project
This commit is contained in:
parent
4df07f2ed9
commit
96a67766bf
@ -33,6 +33,10 @@ func TestAccComputeDisk_basic(t *testing.T) {
|
|||||||
|
|
||||||
func TestAccComputeDisk_from_snapshot_uri(t *testing.T) {
|
func TestAccComputeDisk_from_snapshot_uri(t *testing.T) {
|
||||||
diskName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
diskName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
||||||
|
firstDiskName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
||||||
|
snapshotName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
|
||||||
|
var xpn_host = os.Getenv("GOOGLE_XPN_HOST_PROJECT")
|
||||||
|
|
||||||
var disk compute.Disk
|
var disk compute.Disk
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
@ -41,10 +45,10 @@ func TestAccComputeDisk_from_snapshot_uri(t *testing.T) {
|
|||||||
CheckDestroy: testAccCheckComputeDiskDestroy,
|
CheckDestroy: testAccCheckComputeDiskDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccComputeDisk_from_snapshot_uri(diskName),
|
Config: testAccComputeDisk_from_snapshot_uri(firstDiskName, snapshotName, diskName, xpn_host),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckComputeDiskExists(
|
testAccCheckComputeDiskExists(
|
||||||
"google_compute_disk.foobar", &disk),
|
"google_compute_disk.seconddisk", &disk),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -151,15 +155,29 @@ resource "google_compute_disk" "foobar" {
|
|||||||
}`, diskName)
|
}`, diskName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccComputeDisk_from_snapshot_uri(diskName string) string {
|
func testAccComputeDisk_from_snapshot_uri(firstDiskName string, snapshotName string, diskName string, xpn_host string) string {
|
||||||
uri := os.Getenv("GOOGLE_COMPUTE_DISK_SNAPSHOT_URI")
|
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
resource "google_compute_disk" "foobar" {
|
resource "google_compute_disk" "foobar" {
|
||||||
|
name = "%s"
|
||||||
|
image = "debian-8-jessie-v20160803"
|
||||||
|
size = 50
|
||||||
|
type = "pd-ssd"
|
||||||
|
zone = "us-central1-a"
|
||||||
|
project = "%s"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "google_compute_snapshot" "snapdisk" {
|
||||||
|
name = "%s"
|
||||||
|
source_disk = "${google_compute_disk.foobar.name}"
|
||||||
|
zone = "us-central1-a"
|
||||||
|
project = "%s"
|
||||||
|
}
|
||||||
|
resource "google_compute_disk" "seconddisk" {
|
||||||
name = "%s"
|
name = "%s"
|
||||||
snapshot = "%s"
|
snapshot = "${google_compute_snapshot.snapdisk.self_link}"
|
||||||
type = "pd-ssd"
|
type = "pd-ssd"
|
||||||
zone = "us-central1-a"
|
zone = "us-central1-a"
|
||||||
}`, diskName, uri)
|
}`, firstDiskName, xpn_host, snapshotName, xpn_host, diskName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccComputeDisk_encryption(diskName string) string {
|
func testAccComputeDisk_encryption(diskName string) string {
|
||||||
|
Loading…
Reference in New Issue
Block a user