@@ -122,27 +122,28 @@ func TestAccLibvirtVolume_Basic(t *testing.T) {
122
122
func TestAccLibvirtVolume_BackingStoreTestByID (t * testing.T ) {
123
123
var volume libvirt.StorageVol
124
124
var volume2 libvirt.StorageVol
125
- randomVolumeResource := acctest .RandString (10 )
126
- randomVolumeName := acctest .RandString (10 )
125
+ random := acctest .RandString (10 )
127
126
resource .Test (t , resource.TestCase {
128
127
PreCheck : func () { testAccPreCheck (t ) },
129
128
Providers : testAccProviders ,
130
129
CheckDestroy : testAccCheckLibvirtVolumeDestroy ,
131
130
Steps : []resource.TestStep {
132
131
{
133
132
Config : fmt .Sprintf (`
134
- resource "libvirt_volume" "%s" {
135
- name = "%s"
133
+ resource "libvirt_volume" "backing- %s" {
134
+ name = "backing- %s"
136
135
size = 1073741824
137
136
}
138
- resource "libvirt_volume" "backing-store " {
139
- name = "backing-store "
140
- base_volume_id = "${libvirt_volume.%s.id}"
137
+ resource "libvirt_volume" "%s " {
138
+ name = "%s "
139
+ base_volume_id = "${libvirt_volume.backing- %s.id}"
141
140
}
142
- ` , randomVolumeResource , randomVolumeName , randomVolumeResource ),
141
+ ` , random , random , random , random , random ),
143
142
Check : resource .ComposeTestCheckFunc (
144
- testAccCheckLibvirtVolumeExists ("libvirt_volume." + randomVolumeResource , & volume ),
145
- testAccCheckLibvirtVolumeIsBackingStore ("libvirt_volume.backing-store" , & volume2 ),
143
+ testAccCheckLibvirtVolumeExists ("libvirt_volume.backing-" + random , & volume ),
144
+ testAccCheckLibvirtVolumeIsBackingStore ("libvirt_volume." + random , & volume2 ),
145
+ resource .TestCheckResourceAttr (
146
+ "libvirt_volume." + random , "size" , "1073741824" ),
146
147
),
147
148
},
148
149
},
@@ -152,26 +153,28 @@ func TestAccLibvirtVolume_BackingStoreTestByID(t *testing.T) {
152
153
func TestAccLibvirtVolume_BackingStoreTestByName (t * testing.T ) {
153
154
var volume libvirt.StorageVol
154
155
var volume2 libvirt.StorageVol
155
- randomVolumeResource := acctest .RandString (10 )
156
- randomVolumeName := acctest .RandString (10 )
156
+ random := acctest .RandString (10 )
157
157
resource .Test (t , resource.TestCase {
158
158
PreCheck : func () { testAccPreCheck (t ) },
159
159
Providers : testAccProviders ,
160
160
CheckDestroy : testAccCheckLibvirtVolumeDestroy ,
161
161
Steps : []resource.TestStep {
162
162
{
163
163
Config : fmt .Sprintf (`
164
- resource "libvirt_volume" "%s" {
165
- name = "%s"
166
- size = 1073741824
167
- }
168
- resource "libvirt_volume" "backing-store" {
169
- name = "backing-store"
170
- base_volume_name = "${libvirt_volume.%s.name}"
171
- } ` , randomVolumeResource , randomVolumeName , randomVolumeResource ),
164
+ resource "libvirt_volume" "backing-%s" {
165
+ name = "backing-%s"
166
+ size = 1073741824
167
+ }
168
+ resource "libvirt_volume" "%s" {
169
+ name = "%s"
170
+ base_volume_name = "${libvirt_volume.backing-%s.name}"
171
+ }
172
+ ` , random , random , random , random , random ),
172
173
Check : resource .ComposeTestCheckFunc (
173
- testAccCheckLibvirtVolumeExists ("libvirt_volume." + randomVolumeResource , & volume ),
174
- testAccCheckLibvirtVolumeIsBackingStore ("libvirt_volume.backing-store" , & volume2 ),
174
+ testAccCheckLibvirtVolumeExists ("libvirt_volume.backing-" + random , & volume ),
175
+ testAccCheckLibvirtVolumeIsBackingStore ("libvirt_volume." + random , & volume2 ),
176
+ resource .TestCheckResourceAttr (
177
+ "libvirt_volume." + random , "size" , "1073741824" ),
175
178
),
176
179
},
177
180
},
0 commit comments