@@ -18,6 +18,7 @@ package readiness_test
18
18
19
19
import (
20
20
"context"
21
+ "encoding/json"
21
22
"fmt"
22
23
"testing"
23
24
"time"
@@ -27,6 +28,7 @@ import (
27
28
"github.com/stretchr/testify/assert"
28
29
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
30
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
31
+ "k8s.io/apimachinery/pkg/types"
30
32
31
33
"github.com/deckhouse/deckhouse/pkg/log"
32
34
@@ -64,27 +66,27 @@ func Test_CheckModuleReadiness(t *testing.T) {
64
66
},
65
67
}
66
68
67
- updatedResource := & unstructured.Unstructured {
68
- Object : map [string ]interface {}{
69
- "status" : map [string ]interface {}{
70
- "conditions" : []interface {}{
71
- map [string ]interface {}{
72
- "type" : "IsReady" ,
73
- "status" : "True" ,
74
- "lastTransitionTime" : "2006-01-02T15:04:05Z" ,
75
- },
69
+ patch , err := json .Marshal (map [string ]any {
70
+ "status" : map [string ]interface {}{
71
+ "conditions" : []interface {}{
72
+ map [string ]interface {}{
73
+ "type" : "IsReady" ,
74
+ "status" : "True" ,
75
+ "lastTransitionTime" : "2006-01-02T15:04:05Z" ,
76
+ "lastProbeTime" : "2006-01-02T15:04:05Z" ,
76
77
},
77
- "phase" : "Ready" ,
78
78
},
79
+ "phase" : "Ready" ,
79
80
},
80
- }
81
+ })
82
+ assert .NoError (t , err )
81
83
82
84
resourceMock := mock .NewKubernetesNamespaceableResourceInterfaceMock (mc )
83
85
resourceMock .GetMock .
84
86
Expect (minimock .AnyContext , "stub" , metav1.GetOptions {}).
85
87
Return (resource , nil )
86
- resourceMock .ApplyStatusMock .
87
- Expect (minimock .AnyContext , "stub" , updatedResource , metav1.ApplyOptions {} ).
88
+ resourceMock .PatchMock .
89
+ Expect (minimock .AnyContext , "stub" , types . MergePatchType , patch , metav1.PatchOptions {}, "status" ).
88
90
Return (nil , nil )
89
91
90
92
dynamicClientMock := mock .NewKubernetesDynamicClientMock (mc )
@@ -215,27 +217,27 @@ func Test_CheckModuleReadiness(t *testing.T) {
215
217
},
216
218
}
217
219
218
- updatedResource := & unstructured.Unstructured {
219
- Object : map [string ]interface {}{
220
- "status" : map [string ]interface {}{
221
- "conditions" : []interface {}{
222
- map [string ]interface {}{
223
- "type" : "IsReady" ,
224
- "status" : "True" ,
225
- "lastTransitionTime" : "2006-01-02T15:04:05Z" ,
226
- },
220
+ patch , err := json .Marshal (map [string ]any {
221
+ "status" : map [string ]interface {}{
222
+ "conditions" : []interface {}{
223
+ map [string ]interface {}{
224
+ "type" : "IsReady" ,
225
+ "status" : "True" ,
226
+ "lastTransitionTime" : "2006-01-02T15:04:05Z" ,
227
+ "lastProbeTime" : "2006-01-02T15:04:05Z" ,
227
228
},
228
- "phase" : "Ready" ,
229
229
},
230
+ "phase" : "Ready" ,
230
231
},
231
- }
232
+ })
233
+ assert .NoError (t , err )
232
234
233
235
resourceMock := mock .NewKubernetesNamespaceableResourceInterfaceMock (mc )
234
236
resourceMock .GetMock .
235
237
Expect (minimock .AnyContext , "stub" , metav1.GetOptions {}).
236
238
Return (resource , nil )
237
- resourceMock .ApplyStatusMock .
238
- Expect (minimock .AnyContext , "stub" , updatedResource , metav1.ApplyOptions {} ).
239
+ resourceMock .PatchMock .
240
+ Expect (minimock .AnyContext , "stub" , types . MergePatchType , patch , metav1.PatchOptions {}, "status" ).
239
241
Return (nil , fmt .Errorf ("update error" ))
240
242
241
243
dynamicClientMock := mock .NewKubernetesDynamicClientMock (mc )
0 commit comments