Skip to content

Commit 925feee

Browse files
committed
fix: increased coverage for controller/apibinding_controller
1 parent 63f9d4e commit 925feee

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

listener/controller/apibinding_controller_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,27 @@ func TestAPIBindingReconciler_Reconcile(t *testing.T) {
137137
},
138138
err: assert.AnError,
139139
},
140+
{
141+
name: "successful_schema_update",
142+
clusterName: "dev-cluster",
143+
mockSetup: func(ioHandler *workspacefileMocks.MockIOHandler, discoverFactory *discoveryclientMocks.MockFactory, apiSchemaResolver *apischemaMocks.MockResolver, clusterPathResolver *clusterpathMocks.MockResolver) {
144+
controllerRuntimeClient := &controllerRuntimeMocks.MockClient{}
145+
clusterPathResolver.EXPECT().ClientForCluster("dev-cluster").Return(controllerRuntimeClient, nil)
146+
controllerRuntimeClient.EXPECT().Get(mock.Anything, mock.Anything, mock.Anything).Return(nil).
147+
Run(func(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) {
148+
lc := obj.(*kcpcore.LogicalCluster)
149+
lc.Annotations = map[string]string{
150+
"kcp.io/path": "dev-cluster",
151+
}
152+
})
153+
ioHandler.EXPECT().Read("dev-cluster").Return([]byte("{}"), nil)
154+
discoverFactory.EXPECT().RestMapperForCluster("dev-cluster").Return(nil, nil)
155+
discoverFactory.EXPECT().ClientForCluster("dev-cluster").Return(nil, nil)
156+
apiSchemaResolver.EXPECT().Resolve(nil, nil).Return([]byte(`{"new":"schema"}`), nil)
157+
ioHandler.EXPECT().Write([]byte(`{"new":"schema"}`), "dev-cluster").Return(nil)
158+
},
159+
err: nil,
160+
},
140161
}
141162

142163
log := testlogger.New().HideLogOutput().Logger

0 commit comments

Comments
 (0)