@@ -46,19 +46,21 @@ var _ = Describe("Instance", func() {
46
46
unknownError := errors .New (unknownErrorMessage )
47
47
48
48
var (
49
- mockCtrl * gomock.Controller
50
- mockClient * cloudstack.CloudStackClient
51
- vms * cloudstack.MockVirtualMachineServiceIface
52
- sos * cloudstack.MockServiceOfferingServiceIface
53
- dos * cloudstack.MockDiskOfferingServiceIface
54
- ts * cloudstack.MockTemplateServiceIface
55
- vs * cloudstack.MockVolumeServiceIface
56
- client cloud.Client
49
+ mockCtrl * gomock.Controller
50
+ mockClient * cloudstack.CloudStackClient
51
+ configuration * cloudstack.MockConfigurationServiceIface
52
+ vms * cloudstack.MockVirtualMachineServiceIface
53
+ sos * cloudstack.MockServiceOfferingServiceIface
54
+ dos * cloudstack.MockDiskOfferingServiceIface
55
+ ts * cloudstack.MockTemplateServiceIface
56
+ vs * cloudstack.MockVolumeServiceIface
57
+ client cloud.Client
57
58
)
58
59
59
60
BeforeEach (func () {
60
61
mockCtrl = gomock .NewController (GinkgoT ())
61
62
mockClient = cloudstack .NewMockClient (mockCtrl )
63
+ configuration = mockClient .Configuration .(* cloudstack.MockConfigurationServiceIface )
62
64
vms = mockClient .VirtualMachine .(* cloudstack.MockVirtualMachineServiceIface )
63
65
sos = mockClient .ServiceOffering .(* cloudstack.MockServiceOfferingServiceIface )
64
66
dos = mockClient .DiskOffering .(* cloudstack.MockDiskOfferingServiceIface )
@@ -872,8 +874,12 @@ var _ = Describe("Instance", func() {
872
874
})
873
875
874
876
Context ("when destroying a VM instance" , func () {
877
+ listCapabilitiesParams := & cloudstack.ListCapabilitiesParams {}
875
878
expungeDestroyParams := & cloudstack.DestroyVirtualMachineParams {}
876
879
expungeDestroyParams .SetExpunge (true )
880
+ listCapabilitiesResponse := & cloudstack.ListCapabilitiesResponse {
881
+ Capabilities : & cloudstack.Capability {Allowuserexpungerecovervm : true },
882
+ }
877
883
listVolumesParams := & cloudstack.ListVolumesParams {}
878
884
listVolumesResponse := & cloudstack.ListVolumesResponse {
879
885
Volumes : []* cloudstack.Volume {
@@ -886,6 +892,11 @@ var _ = Describe("Instance", func() {
886
892
},
887
893
}
888
894
895
+ BeforeEach (func () {
896
+ configuration .EXPECT ().NewListCapabilitiesParams ().Return (listCapabilitiesParams )
897
+ configuration .EXPECT ().ListCapabilities (listCapabilitiesParams ).Return (listCapabilitiesResponse , nil )
898
+ })
899
+
889
900
It ("calls destroy and finds VM doesn't exist, then returns nil" , func () {
890
901
listVolumesParams .SetVirtualmachineid (* dummies .CSMachine1 .Spec .InstanceID )
891
902
listVolumesParams .SetType ("DATADISK" )
0 commit comments