5
5
"errors"
6
6
"testing"
7
7
8
+ "github.com/prometheus/client_golang/prometheus"
8
9
"github.com/stretchr/testify/assert"
9
10
"github.com/stretchr/testify/mock"
10
11
"k8s.io/apimachinery/pkg/api/meta"
@@ -22,6 +23,8 @@ var failingObj = &example.Pod{TypeMeta: metav1.TypeMeta{Kind: "foo"}, ObjectMeta
22
23
var exampleList = & example.PodList {TypeMeta : metav1.TypeMeta {Kind : "foo" }, ListMeta : metav1.ListMeta {}, Items : []example.Pod {* exampleObj }}
23
24
var anotherList = & example.PodList {Items : []example.Pod {* anotherObj }}
24
25
26
+ var p = prometheus .NewRegistry ()
27
+
25
28
func TestMode1_Create (t * testing.T ) {
26
29
type testCase struct {
27
30
input runtime.Object
@@ -68,7 +71,7 @@ func TestMode1_Create(t *testing.T) {
68
71
tt .setupStorageFn (m )
69
72
}
70
73
71
- dw := NewDualWriter (Mode1 , ls , us )
74
+ dw := NewDualWriter (Mode1 , ls , us , p )
72
75
73
76
obj , err := dw .Create (context .Background (), tt .input , func (context.Context , runtime.Object ) error { return nil }, & metav1.CreateOptions {})
74
77
@@ -131,7 +134,8 @@ func TestMode1_Get(t *testing.T) {
131
134
tt .setupStorageFn (m , tt .input )
132
135
}
133
136
134
- dw := NewDualWriter (Mode1 , ls , us )
137
+ p := prometheus .NewRegistry ()
138
+ dw := NewDualWriter (Mode1 , ls , us , p )
135
139
136
140
obj , err := dw .Get (context .Background (), tt .input , & metav1.GetOptions {})
137
141
@@ -182,7 +186,7 @@ func TestMode1_List(t *testing.T) {
182
186
tt .setupStorageFn (m )
183
187
}
184
188
185
- dw := NewDualWriter (Mode1 , ls , us )
189
+ dw := NewDualWriter (Mode1 , ls , us , p )
186
190
187
191
_ , err := dw .List (context .Background (), & metainternalversion.ListOptions {})
188
192
@@ -237,7 +241,7 @@ func TestMode1_Delete(t *testing.T) {
237
241
tt .setupStorageFn (m , tt .input )
238
242
}
239
243
240
- dw := NewDualWriter (Mode1 , ls , us )
244
+ dw := NewDualWriter (Mode1 , ls , us , p )
241
245
242
246
obj , _ , err := dw .Delete (context .Background (), tt .input , func (ctx context.Context , obj runtime.Object ) error { return nil }, & metav1.DeleteOptions {})
243
247
@@ -296,7 +300,7 @@ func TestMode1_DeleteCollection(t *testing.T) {
296
300
tt .setupStorageFn (m , tt .input )
297
301
}
298
302
299
- dw := NewDualWriter (Mode1 , ls , us )
303
+ dw := NewDualWriter (Mode1 , ls , us , p )
300
304
301
305
obj , err := dw .DeleteCollection (context .Background (), func (ctx context.Context , obj runtime.Object ) error { return nil }, tt .input , & metainternalversion.ListOptions {})
302
306
@@ -372,7 +376,7 @@ func TestMode1_Update(t *testing.T) {
372
376
tt .setupGetFn (m , tt .input )
373
377
}
374
378
375
- dw := NewDualWriter (Mode1 , ls , us )
379
+ dw := NewDualWriter (Mode1 , ls , us , p )
376
380
377
381
obj , _ , err := dw .Update (context .Background (), tt .input , updatedObjInfoObj {}, func (ctx context.Context , obj runtime.Object ) error { return nil }, func (ctx context.Context , obj , old runtime.Object ) error { return nil }, false , & metav1.UpdateOptions {})
378
382
0 commit comments