Skip to content

Commit

Permalink
fix(): broken UTs
Browse files Browse the repository at this point in the history
Signed-off-by: gourishkb <[email protected]>
  • Loading branch information
gourishkb committed Feb 16, 2024
1 parent d029a25 commit 2db524a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
35 changes: 32 additions & 3 deletions pkg/hub/controllers/slice_controller_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
workerv1alpha1 "github.com/kubeslice/apis/pkg/worker/v1alpha1"
mevents "github.com/kubeslice/kubeslice-monitoring/pkg/events"
"github.com/kubeslice/kubeslice-monitoring/pkg/metrics"
"github.com/kubeslice/worker-operator/api/v1beta1"
kubeslicev1beta1 "github.com/kubeslice/worker-operator/api/v1beta1"
ossEvents "github.com/kubeslice/worker-operator/events"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -211,14 +210,24 @@ func TestReconcileToUpdateWorkerSlice(t *testing.T) {
).Return(nil)
client.On("List",
mock.IsType(ctx),
mock.IsType(&v1beta1.SliceGatewayList{}),
mock.IsType(&kubeslicev1beta1.SliceGatewayList{}),
mock.IsType([]k8sclient.ListOption{}),
).Return(nil)
client.StatusMock.On("Update",
mock.IsType(ctx),
mock.IsType(&workerv1alpha1.WorkerSliceConfig{}),
mock.IsType([]k8sclient.UpdateOption(nil)),
).Return(nil)
client.StatusMock.On("Update",
mock.IsType(ctx),
mock.IsType(&workerv1alpha1.WorkerSliceConfig{}),
mock.IsType([]k8sclient.SubResourceUpdateOption(nil)),
).Return(nil)
client.StatusMock.On("Update",
mock.IsType(ctx),
mock.IsType(&kubeslicev1beta1.Slice{}),
mock.IsType([]k8sclient.SubResourceUpdateOption(nil)),
).Return(nil)

mf, _ := metrics.NewMetricsFactory(prometheus.NewRegistry(), metrics.MetricsFactoryOptions{})
eventRecorder := mevents.NewEventRecorder(client, &runtime.Scheme{}, ossEvents.EventsMap, mevents.EventRecorderOptions{
Expand Down Expand Up @@ -261,6 +270,16 @@ func TestUpdateSliceConfig(t *testing.T) {
mock.IsType(&kubeslicev1beta1.Slice{}),
mock.IsType([]k8sclient.UpdateOption(nil)),
).Return(nil)
client.StatusMock.On("Update",
mock.IsType(ctx),
mock.IsType(&kubeslicev1beta1.Slice{}),
mock.IsType([]k8sclient.SubResourceUpdateOption(nil)),
).Return(nil)
client.StatusMock.On("Update",
mock.IsType(ctx),
mock.IsType(&workerv1alpha1.WorkerSliceConfig{}),
mock.IsType([]k8sclient.SubResourceUpdateOption(nil)),
).Return(nil)
err := reconciler.updateSliceConfig(expected.ctx, workerslice, controllerSlice)
if expected.err != err {
t.Error("Expected error:", expected.err, " but got ", err)
Expand Down Expand Up @@ -304,7 +323,7 @@ func TestUpdateSliceHealth(t *testing.T) {
).Return(nil)
client.On("List",
mock.IsType(ctx),
mock.IsType(&v1beta1.SliceGatewayList{}),
mock.IsType(&kubeslicev1beta1.SliceGatewayList{}),
mock.IsType([]k8sclient.ListOption{}),
).Return(nil)
client.On("List",
Expand Down Expand Up @@ -345,6 +364,16 @@ func TestUpdateSliceConfigByModyfingSubnetOfControllerSlice(t *testing.T) {
mock.IsType(workerslice),
mock.IsType([]k8sclient.UpdateOption(nil)),
).Return(nil)
client.StatusMock.On("Update",
mock.IsType(ctx),
mock.IsType(&workerv1alpha1.WorkerSliceConfig{}),
mock.IsType([]k8sclient.SubResourceUpdateOption(nil)),
).Return(nil)
client.StatusMock.On("Update",
mock.IsType(ctx),
mock.IsType(&kubeslicev1beta1.Slice{}),
mock.IsType([]k8sclient.SubResourceUpdateOption(nil)),
).Return(nil)
controllerSlice.Spec.SliceSubnet = "10.0.0.2/16"
workerslice.Status = kubeslicev1beta1.SliceStatus{}
err := reconciler.updateSliceConfig(expected.ctx, workerslice, controllerSlice)
Expand Down
1 change: 1 addition & 0 deletions tests/hub/hub_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ var _ = BeforeSuite(func() {
sr.ReconcileInterval = 5 * time.Second

sgwr := &controllers.SliceGwReconciler{
Client: k8sClient,
MeshClient: k8sClient,
EventRecorder: &testSliceEventRecorder,
ClusterName: CLUSTER_NAME,
Expand Down

0 comments on commit 2db524a

Please sign in to comment.