@@ -28,6 +28,7 @@ import (
2828 apierrors "k8s.io/apimachinery/pkg/api/errors"
2929 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
31+ "k8s.io/apimachinery/pkg/runtime"
3132 "k8s.io/apimachinery/pkg/runtime/schema"
3233 "k8s.io/apimachinery/pkg/util/intstr"
3334 "k8s.io/client-go/tools/record"
@@ -2353,7 +2354,10 @@ func TestMachineSetReconciler_syncReplicas(t *testing.T) {
23532354func TestMachineSetReconciler_syncReplicas_WithErrors (t * testing.T ) {
23542355 t .Run ("should hold off on sync replicas when create Infrastructure of machine failed " , func (t * testing.T ) {
23552356 g := NewWithT (t )
2356- fakeClient := fake .NewClientBuilder ().WithObjects ().WithInterceptorFuncs (interceptor.Funcs {
2357+ scheme := runtime .NewScheme ()
2358+ g .Expect (clusterv1 .AddToScheme (scheme )).To (Succeed ())
2359+
2360+ fakeClient := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects ().WithInterceptorFuncs (interceptor.Funcs {
23572361 Create : func (ctx context.Context , client client.WithWatch , obj client.Object , opts ... client.CreateOption ) error {
23582362 // simulate scenarios where infra object creation fails
23592363 if obj .GetObjectKind ().GroupVersionKind ().Kind == "GenericInfrastructureMachine" {
@@ -2366,10 +2370,13 @@ func TestMachineSetReconciler_syncReplicas_WithErrors(t *testing.T) {
23662370 r := & Reconciler {
23672371 Client : fakeClient ,
23682372 }
2369- testCluster := & clusterv1.Cluster {}
2370- testCluster .Namespace = "default"
2371- testCluster .Name = "test-cluster"
2372- version := "v1.14.2"
2373+ testCluster := & clusterv1.Cluster {
2374+ ObjectMeta : metav1.ObjectMeta {
2375+ Name : "test-cluster" ,
2376+ Namespace : "default" ,
2377+ },
2378+ }
2379+
23732380 duration10m := & metav1.Duration {Duration : 10 * time .Minute }
23742381 machineSet := & clusterv1.MachineSet {
23752382 ObjectMeta : metav1.ObjectMeta {
@@ -2383,7 +2390,7 @@ func TestMachineSetReconciler_syncReplicas_WithErrors(t *testing.T) {
23832390 Template : clusterv1.MachineTemplateSpec {
23842391 Spec : clusterv1.MachineSpec {
23852392 ClusterName : testCluster .Name ,
2386- Version : & version ,
2393+ Version : ptr . To ( "v1.14.2" ) ,
23872394 Bootstrap : clusterv1.Bootstrap {
23882395 ConfigRef : & corev1.ObjectReference {
23892396 APIVersion : "bootstrap.cluster.x-k8s.io/v1beta1" ,
@@ -2416,6 +2423,7 @@ func TestMachineSetReconciler_syncReplicas_WithErrors(t *testing.T) {
24162423 },
24172424 },
24182425 }
2426+
24192427 bootstrapTmpl := & unstructured.Unstructured {
24202428 Object : map [string ]interface {}{
24212429 "spec" : map [string ]interface {}{
0 commit comments