@@ -33,6 +33,10 @@ func TestAccComputeDisk_basic(t *testing.T) {
3333
3434func TestAccComputeDisk_from_snapshot_uri (t * testing.T ) {
3535 diskName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (10 ))
36+ firstDiskName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (10 ))
37+ snapshotName := fmt .Sprintf ("tf-test-%s" , acctest .RandString (10 ))
38+ var xpn_host = os .Getenv ("GOOGLE_XPN_HOST_PROJECT" )
39+
3640 var disk compute.Disk
3741
3842 resource .Test (t , resource.TestCase {
@@ -41,10 +45,10 @@ func TestAccComputeDisk_from_snapshot_uri(t *testing.T) {
4145 CheckDestroy : testAccCheckComputeDiskDestroy ,
4246 Steps : []resource.TestStep {
4347 resource.TestStep {
44- Config : testAccComputeDisk_from_snapshot_uri (diskName ),
48+ Config : testAccComputeDisk_from_snapshot_uri (firstDiskName , snapshotName , diskName , xpn_host ),
4549 Check : resource .ComposeTestCheckFunc (
4650 testAccCheckComputeDiskExists (
47- "google_compute_disk.foobar " , & disk ),
51+ "google_compute_disk.seconddisk " , & disk ),
4852 ),
4953 },
5054 },
@@ -151,15 +155,29 @@ resource "google_compute_disk" "foobar" {
151155}` , diskName )
152156}
153157
154- func testAccComputeDisk_from_snapshot_uri (diskName string ) string {
155- uri := os .Getenv ("GOOGLE_COMPUTE_DISK_SNAPSHOT_URI" )
158+ func testAccComputeDisk_from_snapshot_uri (firstDiskName string , snapshotName string , diskName string , xpn_host string ) string {
156159 return fmt .Sprintf (`
157- resource "google_compute_disk" "foobar" {
160+ resource "google_compute_disk" "foobar" {
161+ name = "%s"
162+ image = "debian-8-jessie-v20160803"
163+ size = 50
164+ type = "pd-ssd"
165+ zone = "us-central1-a"
166+ project = "%s"
167+ }
168+
169+ resource "google_compute_snapshot" "snapdisk" {
170+ name = "%s"
171+ source_disk = "${google_compute_disk.foobar.name}"
172+ zone = "us-central1-a"
173+ project = "%s"
174+ }
175+ resource "google_compute_disk" "seconddisk" {
158176 name = "%s"
159- snapshot = "%s "
177+ snapshot = "${google_compute_snapshot.snapdisk.self_link} "
160178 type = "pd-ssd"
161179 zone = "us-central1-a"
162- }` , diskName , uri )
180+ }` , firstDiskName , xpn_host , snapshotName , xpn_host , diskName )
163181}
164182
165183func testAccComputeDisk_encryption (diskName string ) string {
0 commit comments