@@ -158,55 +158,6 @@ func TestVolumeAPIs(t *testing.T) {
158158 })
159159}
160160
161- // volumeInit initializes a volume, it creates a VHD, initializes it,
162- // creates a partition with the max size and formats the volume corresponding to that partition
163- func volumeInit (volumeClient volume.Interface , t * testing.T ) (* VirtualHardDisk , string , func ()) {
164- vhd , vhdCleanup := diskInit (t )
165-
166- listRequest := & volume.ListVolumesOnDiskRequest {
167- DiskNumber : vhd .DiskNumber ,
168- }
169- listResponse , err := volumeClient .ListVolumesOnDisk (context .TODO (), listRequest )
170- if err != nil {
171- t .Fatalf ("List response: %v" , err )
172- }
173-
174- volumeIDsLen := len (listResponse .VolumeIds )
175- if volumeIDsLen != 1 {
176- t .Fatalf ("Number of volumes not equal to 1: %d" , volumeIDsLen )
177- }
178- volumeID := listResponse .VolumeIds [0 ]
179- t .Logf ("VolumeId %v" , volumeID )
180-
181- isVolumeFormattedRequest := & volume.IsVolumeFormattedRequest {
182- VolumeId : volumeID ,
183- }
184- isVolumeFormattedResponse , err := volumeClient .IsVolumeFormatted (context .TODO (), isVolumeFormattedRequest )
185- if err != nil {
186- t .Fatalf ("Is volume formatted request error: %v" , err )
187- }
188- if isVolumeFormattedResponse .Formatted {
189- t .Fatal ("Volume formatted. Unexpected !!" )
190- }
191-
192- formatVolumeRequest := & volume.FormatVolumeRequest {
193- VolumeId : volumeID ,
194- }
195- _ , err = volumeClient .FormatVolume (context .TODO (), formatVolumeRequest )
196- if err != nil {
197- t .Fatalf ("Volume format failed. Error: %v" , err )
198- }
199-
200- isVolumeFormattedResponse , err = volumeClient .IsVolumeFormatted (context .TODO (), isVolumeFormattedRequest )
201- if err != nil {
202- t .Fatalf ("Is volume formatted request error: %v" , err )
203- }
204- if ! isVolumeFormattedResponse .Formatted {
205- t .Fatal ("Volume should be formatted. Unexpected !!" )
206- }
207- return vhd , volumeID , vhdCleanup
208- }
209-
210161func getClosestVolumeFromTargetPathTests (diskClient disk.Interface , volumeClient volume.Interface , t * testing.T ) {
211162 t .Run ("DriveLetterVolume" , func (t * testing.T ) {
212163 vhd , _ , vhdCleanup := volumeInit (volumeClient , t )
@@ -436,21 +387,6 @@ func mountVolumeTests(diskClient disk.Interface, volumeClient volume.Interface,
436387 }
437388}
438389
439- func volumeTests (t * testing.T ) {
440- volumeClient , err := volume .New (volumeapi .New ())
441- require .Nil (t , err )
442-
443- diskClient , err := disk .New (diskapi .New ())
444- require .Nil (t , err )
445-
446- t .Run ("MountVolume" , func (t * testing.T ) {
447- mountVolumeTests (diskClient , volumeClient , t )
448- })
449- t .Run ("GetClosestVolumeFromTargetPath" , func (t * testing.T ) {
450- getClosestVolumeFromTargetPathTests (diskClient , volumeClient , t )
451- })
452- }
453-
454390func TestVolume (t * testing.T ) {
455391 t .Run ("NegativeDiskTests" , func (t * testing.T ) {
456392 negativeDiskTests (t )
@@ -463,8 +399,19 @@ func TestVolume(t *testing.T) {
463399 // see https://github.com/actions/virtual-environments/pull/2525
464400
465401 // these tests should be considered frozen from the API point of view
466- t .Run ("volumeTests" , func (t * testing.T ) {
402+ volumeClient , err := volume .New (volumeapi .New ())
403+ require .Nil (t , err )
404+
405+ diskClient , err := disk .New (diskapi .New ())
406+ require .Nil (t , err )
407+
408+ t .Run ("MountVolume" , func (t * testing.T ) {
467409 skipTestOnCondition (t , isRunningOnGhActions ())
468- volumeTests (t )
410+ mountVolumeTests (diskClient , volumeClient , t )
411+ })
412+
413+ t .Run ("GetClosestVolumeFromTargetPath" , func (t * testing.T ) {
414+ skipTestOnCondition (t , isRunningOnGhActions ())
415+ getClosestVolumeFromTargetPathTests (diskClient , volumeClient , t )
469416 })
470417}
0 commit comments