@@ -45,7 +45,7 @@ import (
45
45
46
46
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha6"
47
47
"sigs.k8s.io/cluster-api-provider-openstack/pkg/clients"
48
- mock_clients "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients/mock"
48
+ "sigs.k8s.io/cluster-api-provider-openstack/pkg/clients/mock"
49
49
"sigs.k8s.io/cluster-api-provider-openstack/pkg/cloud/services/networking"
50
50
"sigs.k8s.io/cluster-api-provider-openstack/pkg/scope"
51
51
)
@@ -183,7 +183,7 @@ func TestService_getServerNetworks(t *testing.T) {
183
183
name string
184
184
networkParams []infrav1.NetworkParam
185
185
want []infrav1.Network
186
- expect func (m * mock_clients .MockNetworkClientMockRecorder )
186
+ expect func (m * mock .MockNetworkClientMockRecorder )
187
187
wantErr bool
188
188
}{
189
189
{
@@ -194,7 +194,7 @@ func TestService_getServerNetworks(t *testing.T) {
194
194
want : []infrav1.Network {
195
195
{ID : networkAUUID , Subnet : & infrav1.Subnet {}},
196
196
},
197
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
197
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
198
198
},
199
199
wantErr : false ,
200
200
},
@@ -207,7 +207,7 @@ func TestService_getServerNetworks(t *testing.T) {
207
207
{ID : networkAUUID , Subnet : & infrav1.Subnet {}},
208
208
{ID : networkBUUID , Subnet : & infrav1.Subnet {}},
209
209
},
210
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
210
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
211
211
// List tagged networks (A & B)
212
212
m .ListNetwork (& testNetworkListOpts ).
213
213
Return ([]networks.Network {testNetworkA , testNetworkB }, nil )
@@ -226,7 +226,7 @@ func TestService_getServerNetworks(t *testing.T) {
226
226
{ID : networkAUUID , Subnet : & infrav1.Subnet {ID : subnetA2UUID }},
227
227
{ID : networkBUUID , Subnet : & infrav1.Subnet {ID : subnetB1UUID }},
228
228
},
229
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
229
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
230
230
// List all tagged subnets in any network (A1, A2, and B1)
231
231
m .ListSubnet (& testSubnetListOpts ).
232
232
Return ([]subnets.Subnet {testSubnetA1 , testSubnetA2 , testSubnetB1 }, nil )
@@ -247,7 +247,7 @@ func TestService_getServerNetworks(t *testing.T) {
247
247
{ID : networkAUUID , Subnet : & infrav1.Subnet {ID : subnetA1UUID }},
248
248
{ID : networkAUUID , Subnet : & infrav1.Subnet {ID : subnetA2UUID }},
249
249
},
250
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
250
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
251
251
// List tagged subnets in network A (A1 & A2)
252
252
networkAFilter := testSubnetListOpts
253
253
networkAFilter .NetworkID = networkAUUID
@@ -269,7 +269,7 @@ func TestService_getServerNetworks(t *testing.T) {
269
269
want : []infrav1.Network {
270
270
{ID : networkAUUID , Subnet : & infrav1.Subnet {ID : subnetA1UUID }},
271
271
},
272
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
272
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
273
273
},
274
274
wantErr : false ,
275
275
},
@@ -289,7 +289,7 @@ func TestService_getServerNetworks(t *testing.T) {
289
289
{ID : networkAUUID , Subnet : & infrav1.Subnet {ID : subnetA1UUID }},
290
290
{ID : networkAUUID , Subnet : & infrav1.Subnet {ID : subnetA2UUID }},
291
291
},
292
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
292
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
293
293
// List tagged subnets in network A
294
294
networkAFilter := testSubnetListOpts
295
295
networkAFilter .NetworkID = networkAUUID
@@ -320,7 +320,7 @@ func TestService_getServerNetworks(t *testing.T) {
320
320
{ID : networkAUUID , Subnet : & infrav1.Subnet {ID : subnetA2UUID }},
321
321
{ID : networkBUUID , Subnet : & infrav1.Subnet {ID : subnetB1UUID }},
322
322
},
323
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
323
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
324
324
// List tagged networks (A & B)
325
325
m .ListNetwork (& testNetworkListOpts ).
326
326
Return ([]networks.Network {testNetworkA , testNetworkB }, nil )
@@ -346,7 +346,7 @@ func TestService_getServerNetworks(t *testing.T) {
346
346
{Filter : testNetworkFilter },
347
347
},
348
348
want : nil ,
349
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
349
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
350
350
// List tagged networks (none for this test)
351
351
m .ListNetwork (& testNetworkListOpts ).Return ([]networks.Network {}, nil )
352
352
},
@@ -364,7 +364,7 @@ func TestService_getServerNetworks(t *testing.T) {
364
364
},
365
365
},
366
366
want : nil ,
367
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
367
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
368
368
// List tagged subnets in network A
369
369
networkAFilter := testSubnetListOpts
370
370
networkAFilter .NetworkID = networkAUUID
@@ -380,7 +380,7 @@ func TestService_getServerNetworks(t *testing.T) {
380
380
}},
381
381
},
382
382
want : nil ,
383
- expect : func (m * mock_clients .MockNetworkClientMockRecorder ) {
383
+ expect : func (m * mock .MockNetworkClientMockRecorder ) {
384
384
},
385
385
wantErr : true ,
386
386
},
@@ -389,7 +389,7 @@ func TestService_getServerNetworks(t *testing.T) {
389
389
for _ , tt := range tests {
390
390
t .Run (tt .name , func (t * testing.T ) {
391
391
mockCtrl := gomock .NewController (t )
392
- mockNetworkClient := mock_clients .NewMockNetworkClient (mockCtrl )
392
+ mockNetworkClient := mock .NewMockNetworkClient (mockCtrl )
393
393
tt .expect (mockNetworkClient .EXPECT ())
394
394
395
395
networkingService := networking .NewTestService (
@@ -420,31 +420,31 @@ func TestService_getImageID(t *testing.T) {
420
420
testName string
421
421
imageUUID string
422
422
imageName string
423
- expect func (m * mock_clients .MockImageClientMockRecorder )
423
+ expect func (m * mock .MockImageClientMockRecorder )
424
424
want string
425
425
wantErr bool
426
426
}{
427
427
{
428
428
testName : "Return image uuid if uuid given" ,
429
429
imageUUID : imageIDC ,
430
430
want : imageIDC ,
431
- expect : func (m * mock_clients .MockImageClientMockRecorder ) {
431
+ expect : func (m * mock .MockImageClientMockRecorder ) {
432
432
},
433
433
wantErr : false ,
434
434
},
435
435
{
436
436
testName : "Return through uuid if both uuid and name given" ,
437
437
imageName : "dummy" ,
438
438
imageUUID : imageIDC ,
439
- expect : func (m * mock_clients .MockImageClientMockRecorder ) {
439
+ expect : func (m * mock .MockImageClientMockRecorder ) {
440
440
},
441
441
want : imageIDC ,
442
442
wantErr : false ,
443
443
},
444
444
{
445
445
testName : "Return image ID" ,
446
446
imageName : "test-image" ,
447
- expect : func (m * mock_clients .MockImageClientMockRecorder ) {
447
+ expect : func (m * mock .MockImageClientMockRecorder ) {
448
448
m .ListImages (images.ListOpts {Name : "test-image" }).Return (
449
449
[]images.Image {{ID : imageIDA , Name : "test-image" }},
450
450
nil )
@@ -455,7 +455,7 @@ func TestService_getImageID(t *testing.T) {
455
455
{
456
456
testName : "Return no results" ,
457
457
imageName : "test-image" ,
458
- expect : func (m * mock_clients .MockImageClientMockRecorder ) {
458
+ expect : func (m * mock .MockImageClientMockRecorder ) {
459
459
m .ListImages (images.ListOpts {Name : "test-image" }).Return (
460
460
[]images.Image {},
461
461
nil )
@@ -466,7 +466,7 @@ func TestService_getImageID(t *testing.T) {
466
466
{
467
467
testName : "Return multiple results" ,
468
468
imageName : "test-image" ,
469
- expect : func (m * mock_clients .MockImageClientMockRecorder ) {
469
+ expect : func (m * mock .MockImageClientMockRecorder ) {
470
470
m .ListImages (images.ListOpts {Name : "test-image" }).Return (
471
471
[]images.Image {
472
472
{ID : imageIDA , Name : "test-image" },
@@ -479,7 +479,7 @@ func TestService_getImageID(t *testing.T) {
479
479
{
480
480
testName : "OpenStack returns error" ,
481
481
imageName : "test-image" ,
482
- expect : func (m * mock_clients .MockImageClientMockRecorder ) {
482
+ expect : func (m * mock .MockImageClientMockRecorder ) {
483
483
m .ListImages (images.ListOpts {Name : "test-image" }).Return (
484
484
nil ,
485
485
fmt .Errorf ("test error" ))
@@ -491,7 +491,7 @@ func TestService_getImageID(t *testing.T) {
491
491
for _ , tt := range tests {
492
492
t .Run (tt .testName , func (t * testing.T ) {
493
493
mockCtrl := gomock .NewController (t )
494
- mockImageClient := mock_clients .NewMockImageClient (mockCtrl )
494
+ mockImageClient := mock .NewMockImageClient (mockCtrl )
495
495
tt .expect (mockImageClient .EXPECT ())
496
496
497
497
s := Service {
@@ -613,7 +613,7 @@ func TestService_ReconcileInstance(t *testing.T) {
613
613
}
614
614
615
615
// Expected calls to create a server with a single default port
616
- expectUseExistingDefaultPort := func (networkRecorder * mock_clients .MockNetworkClientMockRecorder ) {
616
+ expectUseExistingDefaultPort := func (networkRecorder * mock .MockNetworkClientMockRecorder ) {
617
617
// Returning a pre-existing port requires fewer mocks
618
618
networkRecorder .ListPort (ports.ListOpts {
619
619
Name : portName ,
@@ -626,7 +626,7 @@ func TestService_ReconcileInstance(t *testing.T) {
626
626
}, nil )
627
627
}
628
628
629
- expectCreatePort := func (networkRecorder * mock_clients .MockNetworkClientMockRecorder , name string , networkID string ) {
629
+ expectCreatePort := func (networkRecorder * mock .MockNetworkClientMockRecorder , name string , networkID string ) {
630
630
networkRecorder .ListPort (ports.ListOpts {
631
631
Name : name ,
632
632
NetworkID : networkID ,
@@ -655,19 +655,19 @@ func TestService_ReconcileInstance(t *testing.T) {
655
655
}
656
656
657
657
// Expected calls if we delete the network port
658
- expectCleanupDefaultPort := func (networkRecorder * mock_clients .MockNetworkClientMockRecorder ) {
658
+ expectCleanupDefaultPort := func (networkRecorder * mock .MockNetworkClientMockRecorder ) {
659
659
networkRecorder .ListExtensions ()
660
660
networkRecorder .DeletePort (portUUID ).Return (nil )
661
661
}
662
662
663
663
// Expected calls when using default image and flavor
664
- expectDefaultImageAndFlavor := func (computeRecorder * mock_clients .MockComputeClientMockRecorder , imageRecorder * mock_clients .MockImageClientMockRecorder ) {
664
+ expectDefaultImageAndFlavor := func (computeRecorder * mock .MockComputeClientMockRecorder , imageRecorder * mock .MockImageClientMockRecorder ) {
665
665
imageRecorder .ListImages (images.ListOpts {Name : imageName }).Return ([]images.Image {{ID : imageUUID }}, nil )
666
666
computeRecorder .GetFlavorIDFromName (flavorName ).Return (flavorUUID , nil )
667
667
}
668
668
669
669
// Expected calls and custom match function for creating a server
670
- expectCreateServer := func (computeRecorder * mock_clients .MockComputeClientMockRecorder , expectedCreateOpts map [string ]interface {}, wantError bool ) {
670
+ expectCreateServer := func (computeRecorder * mock .MockComputeClientMockRecorder , expectedCreateOpts map [string ]interface {}, wantError bool ) {
671
671
// This nonsense is because ConfigDrive is a bool pointer, so we
672
672
// can't assert its exact contents with gomock.
673
673
// Instead we call ToServerCreateMap() on it to obtain a
@@ -688,13 +688,13 @@ func TestService_ReconcileInstance(t *testing.T) {
688
688
}
689
689
690
690
// Expected calls when polling for server creation
691
- expectServerPoll := func (computeRecorder * mock_clients .MockComputeClientMockRecorder , states []string ) {
691
+ expectServerPoll := func (computeRecorder * mock .MockComputeClientMockRecorder , states []string ) {
692
692
for _ , state := range states {
693
693
computeRecorder .GetServer (instanceUUID ).Return (returnedServer (state ), nil )
694
694
}
695
695
}
696
696
697
- expectServerPollSuccess := func (computeRecorder * mock_clients .MockComputeClientMockRecorder ) {
697
+ expectServerPollSuccess := func (computeRecorder * mock .MockComputeClientMockRecorder ) {
698
698
expectServerPoll (computeRecorder , []string {"ACTIVE" })
699
699
}
700
700
@@ -706,13 +706,13 @@ func TestService_ReconcileInstance(t *testing.T) {
706
706
}
707
707
708
708
// Expected calls when polling for server creation
709
- expectVolumePoll := func (volumeRecorder * mock_clients .MockVolumeClientMockRecorder , states []string ) {
709
+ expectVolumePoll := func (volumeRecorder * mock .MockVolumeClientMockRecorder , states []string ) {
710
710
for _ , state := range states {
711
711
volumeRecorder .GetVolume (volumeUUID ).Return (returnedVolume (state ), nil )
712
712
}
713
713
}
714
714
715
- expectVolumePollSuccess := func (volumeRecorder * mock_clients .MockVolumeClientMockRecorder ) {
715
+ expectVolumePollSuccess := func (volumeRecorder * mock .MockVolumeClientMockRecorder ) {
716
716
expectVolumePoll (volumeRecorder , []string {"available" })
717
717
}
718
718
@@ -721,10 +721,10 @@ func TestService_ReconcileInstance(t *testing.T) {
721
721
// *******************
722
722
723
723
type recorders struct {
724
- compute * mock_clients .MockComputeClientMockRecorder
725
- image * mock_clients .MockImageClientMockRecorder
726
- network * mock_clients .MockNetworkClientMockRecorder
727
- volume * mock_clients .MockVolumeClientMockRecorder
724
+ compute * mock .MockComputeClientMockRecorder
725
+ image * mock .MockImageClientMockRecorder
726
+ network * mock .MockNetworkClientMockRecorder
727
+ volume * mock .MockVolumeClientMockRecorder
728
728
}
729
729
730
730
tests := []struct {
@@ -991,10 +991,10 @@ func TestService_ReconcileInstance(t *testing.T) {
991
991
for _ , tt := range tests {
992
992
t .Run (tt .name , func (t * testing.T ) {
993
993
mockCtrl := gomock .NewController (t )
994
- mockComputeClient := mock_clients .NewMockComputeClient (mockCtrl )
995
- mockImageClient := mock_clients .NewMockImageClient (mockCtrl )
996
- mockNetworkClient := mock_clients .NewMockNetworkClient (mockCtrl )
997
- mockVolumeClient := mock_clients .NewMockVolumeClient (mockCtrl )
994
+ mockComputeClient := mock .NewMockComputeClient (mockCtrl )
995
+ mockImageClient := mock .NewMockImageClient (mockCtrl )
996
+ mockNetworkClient := mock .NewMockNetworkClient (mockCtrl )
997
+ mockVolumeClient := mock .NewMockVolumeClient (mockCtrl )
998
998
999
999
computeRecorder := mockComputeClient .EXPECT ()
1000
1000
imageRecorder := mockImageClient .EXPECT ()
@@ -1043,9 +1043,9 @@ func TestService_DeleteInstance(t *testing.T) {
1043
1043
// *******************
1044
1044
1045
1045
type recorders struct {
1046
- compute * mock_clients .MockComputeClientMockRecorder
1047
- network * mock_clients .MockNetworkClientMockRecorder
1048
- volume * mock_clients .MockVolumeClientMockRecorder
1046
+ compute * mock .MockComputeClientMockRecorder
1047
+ network * mock .MockNetworkClientMockRecorder
1048
+ volume * mock .MockVolumeClientMockRecorder
1049
1049
}
1050
1050
1051
1051
tests := []struct {
@@ -1109,9 +1109,9 @@ func TestService_DeleteInstance(t *testing.T) {
1109
1109
for _ , tt := range tests {
1110
1110
t .Run (tt .name , func (t * testing.T ) {
1111
1111
mockCtrl := gomock .NewController (t )
1112
- mockComputeClient := mock_clients .NewMockComputeClient (mockCtrl )
1113
- mockNetworkClient := mock_clients .NewMockNetworkClient (mockCtrl )
1114
- mockVolumeClient := mock_clients .NewMockVolumeClient (mockCtrl )
1112
+ mockComputeClient := mock .NewMockComputeClient (mockCtrl )
1113
+ mockNetworkClient := mock .NewMockNetworkClient (mockCtrl )
1114
+ mockVolumeClient := mock .NewMockVolumeClient (mockCtrl )
1115
1115
1116
1116
computeRecorder := mockComputeClient .EXPECT ()
1117
1117
networkRecorder := mockNetworkClient .EXPECT ()
0 commit comments