33package main
44
55import (
6+ "testing"
7+
68 "fmt"
79 "regexp"
8- "testing"
910
1011 "github.com/hashicorp/terraform/helper/resource"
1112 "github.com/hashicorp/terraform/terraform"
@@ -20,8 +21,6 @@ type ResourceCoreVolumeTestSuite struct {
2021 Providers map [string ]terraform.ResourceProvider
2122 Config string
2223 ResourceName string
23- Res * baremetal.Volume
24- DeletedRes * baremetal.Volume
2524}
2625
2726func (s * ResourceCoreVolumeTestSuite ) SetupTest () {
@@ -102,6 +101,32 @@ func (s *ResourceCoreVolumeTestSuite) TestCreateResourceCoreVolume_basic() {
102101 }` ,
103102 ExpectNonEmptyPlan : false ,
104103 },
104+ // create a clone off the existing volume
105+ {
106+ Config : s .Config + `
107+ resource "oci_core_volume" "t" {
108+ availability_domain = "${data.oci_identity_availability_domains.ADs.availability_domains.0.name}"
109+ compartment_id = "${var.compartment_id}"
110+ display_name = "-tf-volume"
111+ size_in_gbs = 50
112+ }
113+ resource "oci_core_volume" "u" {
114+ availability_domain = "${data.oci_identity_availability_domains.ADs.availability_domains.0.name}"
115+ compartment_id = "${var.compartment_id}"
116+ display_name = "-tf-volume-clone"
117+ size_in_gbs = 50
118+ source_details {
119+ type = "volume"
120+ id = "${oci_core_volume.t.id}"
121+ }
122+ }` ,
123+ Check : resource .ComposeTestCheckFunc (
124+ resource .TestCheckResourceAttrSet ("oci_core_volume.u" , "source_details.0.id" ),
125+ resource .TestCheckResourceAttr ("oci_core_volume.u" , "display_name" , "-tf-volume-clone" ),
126+ resource .TestCheckResourceAttr ("oci_core_volume.u" , "source_details.0.type" , "volume" ),
127+ resource .TestCheckResourceAttr ("oci_core_volume.u" , "state" , baremetal .ResourceAvailable ),
128+ ),
129+ },
105130 },
106131 })
107132}
0 commit comments