Skip to content

Commit 927ca0a

Browse files
committed
Fix unit tests
1 parent 3bc921a commit 927ca0a

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

pkg/cloud/instance_test.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,21 @@ var _ = Describe("Instance", func() {
4646
unknownError := errors.New(unknownErrorMessage)
4747

4848
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
5758
)
5859

5960
BeforeEach(func() {
6061
mockCtrl = gomock.NewController(GinkgoT())
6162
mockClient = cloudstack.NewMockClient(mockCtrl)
63+
configuration = mockClient.Configuration.(*cloudstack.MockConfigurationServiceIface)
6264
vms = mockClient.VirtualMachine.(*cloudstack.MockVirtualMachineServiceIface)
6365
sos = mockClient.ServiceOffering.(*cloudstack.MockServiceOfferingServiceIface)
6466
dos = mockClient.DiskOffering.(*cloudstack.MockDiskOfferingServiceIface)
@@ -872,8 +874,12 @@ var _ = Describe("Instance", func() {
872874
})
873875

874876
Context("when destroying a VM instance", func() {
877+
listCapabilitiesParams := &cloudstack.ListCapabilitiesParams{}
875878
expungeDestroyParams := &cloudstack.DestroyVirtualMachineParams{}
876879
expungeDestroyParams.SetExpunge(true)
880+
listCapabilitiesResponse := &cloudstack.ListCapabilitiesResponse{
881+
Capabilities: &cloudstack.Capability{Allowuserexpungerecovervm: true},
882+
}
877883
listVolumesParams := &cloudstack.ListVolumesParams{}
878884
listVolumesResponse := &cloudstack.ListVolumesResponse{
879885
Volumes: []*cloudstack.Volume{
@@ -886,6 +892,11 @@ var _ = Describe("Instance", func() {
886892
},
887893
}
888894

895+
BeforeEach(func() {
896+
configuration.EXPECT().NewListCapabilitiesParams().Return(listCapabilitiesParams)
897+
configuration.EXPECT().ListCapabilities(listCapabilitiesParams).Return(listCapabilitiesResponse, nil)
898+
})
899+
889900
It("calls destroy and finds VM doesn't exist, then returns nil", func() {
890901
listVolumesParams.SetVirtualmachineid(*dummies.CSMachine1.Spec.InstanceID)
891902
listVolumesParams.SetType("DATADISK")

0 commit comments

Comments
 (0)