@@ -34,12 +34,13 @@ type mockClusterClientProperties struct {
34
34
name string
35
35
haNodes int
36
36
workerNodes int
37
+ diskSize int
37
38
}
38
39
39
40
func TestClusterCreation (t * testing.T ) {
40
41
resource .Test (t , resource.TestCase {
41
42
IsUnitTest : true ,
42
- Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockSuccess (mockClusterClientProperties {t , "TestClusterCreation" , 1 , 0 }))},
43
+ Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockSuccess (mockClusterClientProperties {t , "TestClusterCreation" , 1 , 0 , 20000 }))},
43
44
Steps : []resource.TestStep {
44
45
{
45
46
Config : testUnitClusterConfig ("some_driver" , "TestClusterCreation" ),
@@ -54,13 +55,13 @@ func TestClusterCreation(t *testing.T) {
54
55
func TestClusterUpdate (t * testing.T ) {
55
56
resource .Test (t , resource.TestCase {
56
57
IsUnitTest : true ,
57
- Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockUpdate (mockClusterClientProperties {t , "TestClusterCreation " , 1 , 0 }))},
58
+ Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockUpdate (mockClusterClientProperties {t , "TestClusterUpdate " , 1 , 0 , 20000 }))},
58
59
Steps : []resource.TestStep {
59
60
{
60
- Config : testUnitClusterConfig ("some_driver" , "TestClusterCreation " ),
61
+ Config : testUnitClusterConfig ("some_driver" , "TestClusterUpdate " ),
61
62
},
62
63
{
63
- Config : testUnitClusterConfig_Update ("some_driver" , "TestClusterCreation " ),
64
+ Config : testUnitClusterConfig_Update ("some_driver" , "TestClusterUpdate " ),
64
65
Check : resource .ComposeTestCheckFunc (
65
66
resource .TestCheckResourceAttr ("minikube_cluster.new" , "addons.2" , "ingress" ),
66
67
),
@@ -72,18 +73,31 @@ func TestClusterUpdate(t *testing.T) {
72
73
func TestClusterHA (t * testing.T ) {
73
74
resource .Test (t , resource.TestCase {
74
75
IsUnitTest : true ,
75
- Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockSuccess (mockClusterClientProperties {t , "TestClusterCreationHA" , 3 , 5 }))},
76
+ Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockSuccess (mockClusterClientProperties {t , "TestClusterCreationHA" , 3 , 5 , 20000 }))},
76
77
Steps : []resource.TestStep {
77
78
{
78
79
Config : testUnitClusterHAConfig ("some_driver" , "TestClusterCreationHA" ),
79
80
},
80
81
},
81
82
})
82
83
}
84
+
85
+ func TestClusterDisk (t * testing.T ) {
86
+ resource .Test (t , resource.TestCase {
87
+ IsUnitTest : true ,
88
+ Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockSuccess (mockClusterClientProperties {t , "TestClusterCreationDisk" , 1 , 0 , 20480 }))},
89
+ Steps : []resource.TestStep {
90
+ {
91
+ Config : testUnitClusterDiskConfig ("some_driver" , "TestClusterCreationDisk" ),
92
+ },
93
+ },
94
+ })
95
+ }
96
+
83
97
func TestClusterWait (t * testing.T ) {
84
98
resource .Test (t , resource.TestCase {
85
99
IsUnitTest : true ,
86
- Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockSuccess (mockClusterClientProperties {t , "TestClusterCreationWait" , 1 , 0 }))},
100
+ Providers : map [string ]* schema.Provider {"minikube" : NewProvider (mockSuccess (mockClusterClientProperties {t , "TestClusterCreationWait" , 1 , 0 , 20000 }))},
87
101
Steps : []resource.TestStep {
88
102
{
89
103
Config : testUnitClusterWaitConfig ("some_driver" , "TestClusterCreationWait" ),
@@ -315,7 +329,7 @@ func TestClusterCreation_HyperV(t *testing.T) {
315
329
func mockUpdate (props mockClusterClientProperties ) schema.ConfigureContextFunc {
316
330
ctrl := gomock .NewController (props .t )
317
331
318
- mockClusterClient := getBaseMockClient (ctrl , props .name , props .haNodes , props .workerNodes )
332
+ mockClusterClient := getBaseMockClient (ctrl , props .name , props .haNodes , props .workerNodes , props . diskSize )
319
333
320
334
gomock .InOrder (
321
335
mockClusterClient .EXPECT ().
@@ -352,7 +366,7 @@ func mockUpdate(props mockClusterClientProperties) schema.ConfigureContextFunc {
352
366
func mockSuccess (props mockClusterClientProperties ) schema.ConfigureContextFunc {
353
367
ctrl := gomock .NewController (props .t )
354
368
355
- mockClusterClient := getBaseMockClient (ctrl , props .name , props .haNodes , props .workerNodes )
369
+ mockClusterClient := getBaseMockClient (ctrl , props .name , props .haNodes , props .workerNodes , props . diskSize )
356
370
357
371
mockClusterClient .EXPECT ().
358
372
GetAddons ().
@@ -370,7 +384,7 @@ func mockSuccess(props mockClusterClientProperties) schema.ConfigureContextFunc
370
384
return configureContext
371
385
}
372
386
373
- func getBaseMockClient (ctrl * gomock.Controller , clusterName string , haNodes int , workerNodes int ) * lib.MockClusterClient {
387
+ func getBaseMockClient (ctrl * gomock.Controller , clusterName string , haNodes int , workerNodes int , diskSize int ) * lib.MockClusterClient {
374
388
mockClusterClient := lib .NewMockClusterClient (ctrl )
375
389
376
390
os .Mkdir ("test_output" , 0755 )
@@ -420,7 +434,7 @@ func getBaseMockClient(ctrl *gomock.Controller, clusterName string, haNodes int,
420
434
Network : clusterSchema ["network" ].Default .(string ),
421
435
Memory : 4096 ,
422
436
CPUs : 2 ,
423
- DiskSize : 20000 ,
437
+ DiskSize : diskSize ,
424
438
Driver : "some_driver" ,
425
439
ListenAddress : clusterSchema ["listen_address" ].Default .(string ),
426
440
HyperkitVpnKitSock : clusterSchema ["hyperkit_vpnkit_sock" ].Default .(string ),
@@ -535,6 +549,17 @@ func testUnitClusterConfig(driver string, clusterName string) string {
535
549
` , driver , clusterName )
536
550
}
537
551
552
+ func testUnitClusterDiskConfig (driver string , clusterName string ) string {
553
+ return fmt .Sprintf (`
554
+ resource "minikube_cluster" "new" {
555
+ driver = "%s"
556
+ cluster_name = "%s"
557
+
558
+ disk_size = "20g"
559
+ }
560
+ ` , driver , clusterName )
561
+ }
562
+
538
563
func testUnitClusterHAConfig (driver string , clusterName string ) string {
539
564
return fmt .Sprintf (`
540
565
resource "minikube_cluster" "new" {
0 commit comments