You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using logger instance as a property helps in Unit Testing business methods of various structures. Alternatively we have to depend on similar mock logic during UT:
funcTestPlannerIsReadyByNodeDiskCount(t*testing.T) {
mockloginfo:=&types.CStorClusterPlan{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
Namespace: "test",
},
}
vartests=map[string]struct {
planner*PlannerisReadybool
}{
"desired disk count == observed disk count": {
planner: &Planner{
storageSetToDesiredDiskCount: map[string]resource.Quantity{
"101": resource.MustParse("1"),
},
storageSetToBlockDevices: map[string][]string{
"101": []string{"bd1"},
},
},
isReady: true,
},
"desired disk count > observed disk count": {
planner: &Planner{
// TODO (@amitkumardas):// Use log as a field in PlannerCStorClusterPlan: mockloginfo,
storageSetToDesiredDiskCount: map[string]resource.Quantity{
"101": resource.MustParse("2"),
},
storageSetToBlockDevices: map[string][]string{
"101": []string{"bd1"},
},
},
isReady: false,
},
"desired disk count < observed disk count": {
planner: &Planner{
storageSetToDesiredDiskCount: map[string]resource.Quantity{
"101": resource.MustParse("2"),
},
storageSetToBlockDevices: map[string][]string{
"101": []string{"bd1", "bd2", "bd3"},
},
},
isReady: true,
},
}
forname, mock:=rangetests {
name:=namemock:=mockt.Run(name, func(t*testing.T) {
got:=mock.planner.isReadyByNodeDiskCount()
ifgot!=mock.isReady {
t.Fatalf("Want %t got %t", mock.isReady, got)
}
})
}
}
The text was updated successfully, but these errors were encountered:
Using logger instance as a property helps in Unit Testing business methods of various structures. Alternatively we have to depend on similar mock logic during UT:
The text was updated successfully, but these errors were encountered: