Skip to content

Commit 4c11d2d

Browse files
assert for empty slice given all false values
1 parent 3ce961f commit 4c11d2d

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

minikube/service/minikube_client_test.go

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -570,30 +570,9 @@ func TestMinikubeClient_ApplyAddons(t *testing.T) {
570570
}
571571

572572
func TestMinikubeClient_GetAddons(t *testing.T) {
573-
ctrl := gomock.NewController(t)
574-
mockCluster := NewMockCluster(ctrl)
575-
mockCluster.EXPECT().
576-
Get(gomock.Any()).
577-
Return(mustload.ClusterController{
578-
Config: &config.ClusterConfig{Addons: map[string]bool{
579-
"addon1": true,
580-
"addon2": false,
581-
"addon3": true,
582-
},
583-
},
584-
})
585573

586574
type fields struct {
587-
clusterConfig config.ClusterConfig
588-
clusterName string
589-
addons []string
590-
isoUrls []string
591-
deleteOnFailure bool
592-
nodes int
593-
TfCreationLock *sync.Mutex
594-
K8sVersion string
595-
nRunner Cluster
596-
dLoader Downloader
575+
addons map[string]bool
597576
}
598577
tests := []struct {
599578
name string
@@ -603,24 +582,40 @@ func TestMinikubeClient_GetAddons(t *testing.T) {
603582
{
604583
name: "Should convert enabled addons into slice",
605584
fields: fields{
606-
nRunner: mockCluster,
585+
addons: map[string]bool{
586+
"addon1": true,
587+
"addon2": false,
588+
"addon3": true,
589+
},
607590
},
608591
want: []string{"addon1", "addon3"},
609592
},
593+
{
594+
name: "Returns empty slice",
595+
fields: fields{
596+
addons: map[string]bool{
597+
"addon1": false,
598+
"addon2": false,
599+
"addon3": false,
600+
},
601+
},
602+
want: []string{},
603+
},
610604
}
611605
for _, tt := range tests {
606+
ctrl := gomock.NewController(t)
607+
mockCluster := NewMockCluster(ctrl)
608+
mockCluster.EXPECT().
609+
Get(gomock.Any()).
610+
Return(mustload.ClusterController{
611+
Config: &config.ClusterConfig{
612+
Addons: tt.fields.addons,
613+
},
614+
})
615+
612616
t.Run(tt.name, func(t *testing.T) {
613617
e := &MinikubeClient{
614-
clusterConfig: tt.fields.clusterConfig,
615-
clusterName: tt.fields.clusterName,
616-
addons: tt.fields.addons,
617-
isoUrls: tt.fields.isoUrls,
618-
deleteOnFailure: tt.fields.deleteOnFailure,
619-
nodes: tt.fields.nodes,
620-
TfCreationLock: tt.fields.TfCreationLock,
621-
K8sVersion: tt.fields.K8sVersion,
622-
nRunner: tt.fields.nRunner,
623-
dLoader: tt.fields.dLoader,
618+
nRunner: mockCluster,
624619
}
625620
got := e.GetAddons()
626621
sort.Strings(got)

0 commit comments

Comments
 (0)