Skip to content

Commit d0b7fbc

Browse files
author
Dmitry Vlasov
committed
update snapshot test (add case with name reference)
1 parent 2f5ad24 commit d0b7fbc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

google/resource_compute_disk_test.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestAccComputeDisk_updateSize(t *testing.T) {
6060
})
6161
}
6262

63-
func TestAccComputeDisk_fromSnapshotURI(t *testing.T) {
63+
func TestAccComputeDisk_fromSnapshot(t *testing.T) {
6464
diskName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
6565
firstDiskName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
6666
snapshotName := fmt.Sprintf("tf-test-%s", acctest.RandString(10))
@@ -74,7 +74,14 @@ func TestAccComputeDisk_fromSnapshotURI(t *testing.T) {
7474
CheckDestroy: testAccCheckComputeDiskDestroy,
7575
Steps: []resource.TestStep{
7676
resource.TestStep{
77-
Config: testAccComputeDisk_fromSnapshotURI(firstDiskName, snapshotName, diskName, xpn_host),
77+
Config: testAccComputeDisk_fromSnapshot(firstDiskName, snapshotName, diskName, xpn_host, "self_link"),
78+
Check: resource.ComposeTestCheckFunc(
79+
testAccCheckComputeDiskExists(
80+
"google_compute_disk.seconddisk", &disk),
81+
),
82+
},
83+
resource.TestStep{
84+
Config: testAccComputeDisk_fromSnapshot(firstDiskName, snapshotName, diskName, xpn_host, "name"),
7885
Check: resource.ComposeTestCheckFunc(
7986
testAccCheckComputeDiskExists(
8087
"google_compute_disk.seconddisk", &disk),
@@ -251,7 +258,7 @@ resource "google_compute_disk" "foobar" {
251258
}`, diskName)
252259
}
253260

254-
func testAccComputeDisk_fromSnapshotURI(firstDiskName, snapshotName, diskName, xpn_host string) string {
261+
func testAccComputeDisk_fromSnapshot(firstDiskName, snapshotName, diskName, xpn_host string, ref_selector string) string {
255262
return fmt.Sprintf(`
256263
resource "google_compute_disk" "foobar" {
257264
name = "%s"
@@ -270,10 +277,10 @@ resource "google_compute_snapshot" "snapdisk" {
270277
}
271278
resource "google_compute_disk" "seconddisk" {
272279
name = "%s"
273-
snapshot = "${google_compute_snapshot.snapdisk.self_link}"
280+
snapshot = "${google_compute_snapshot.snapdisk.%s}"
274281
type = "pd-ssd"
275282
zone = "us-central1-a"
276-
}`, firstDiskName, xpn_host, snapshotName, xpn_host, diskName)
283+
}`, firstDiskName, xpn_host, snapshotName, xpn_host, diskName, ref_selector)
277284
}
278285

279286
func testAccComputeDisk_encryption(diskName string) string {

0 commit comments

Comments
 (0)