@ -5,6 +5,7 @@ import (
"errors"
"testing"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"k8s.io/apimachinery/pkg/api/meta"
@ -22,6 +23,8 @@ var failingObj = &example.Pod{TypeMeta: metav1.TypeMeta{Kind: "foo"}, ObjectMeta
var exampleList = & example . PodList { TypeMeta : metav1 . TypeMeta { Kind : "foo" } , ListMeta : metav1 . ListMeta { } , Items : [ ] example . Pod { * exampleObj } }
var anotherList = & example . PodList { Items : [ ] example . Pod { * anotherObj } }
var p = prometheus . NewRegistry ( )
func TestMode1_Create ( t * testing . T ) {
type testCase struct {
input runtime . Object
@ -68,7 +71,7 @@ func TestMode1_Create(t *testing.T) {
tt . setupStorageFn ( m )
}
dw := NewDualWriter ( Mode1 , ls , us )
dw := NewDualWriter ( Mode1 , ls , us , p )
obj , err := dw . Create ( context . Background ( ) , tt . input , func ( context . Context , runtime . Object ) error { return nil } , & metav1 . CreateOptions { } )
@ -131,7 +134,8 @@ func TestMode1_Get(t *testing.T) {
tt . setupStorageFn ( m , tt . input )
}
dw := NewDualWriter ( Mode1 , ls , us )
p := prometheus . NewRegistry ( )
dw := NewDualWriter ( Mode1 , ls , us , p )
obj , err := dw . Get ( context . Background ( ) , tt . input , & metav1 . GetOptions { } )
@ -182,7 +186,7 @@ func TestMode1_List(t *testing.T) {
tt . setupStorageFn ( m )
}
dw := NewDualWriter ( Mode1 , ls , us )
dw := NewDualWriter ( Mode1 , ls , us , p )
_ , err := dw . List ( context . Background ( ) , & metainternalversion . ListOptions { } )
@ -237,7 +241,7 @@ func TestMode1_Delete(t *testing.T) {
tt . setupStorageFn ( m , tt . input )
}
dw := NewDualWriter ( Mode1 , ls , us )
dw := NewDualWriter ( Mode1 , ls , us , p )
obj , _ , err := dw . Delete ( context . Background ( ) , tt . input , func ( ctx context . Context , obj runtime . Object ) error { return nil } , & metav1 . DeleteOptions { } )
@ -296,7 +300,7 @@ func TestMode1_DeleteCollection(t *testing.T) {
tt . setupStorageFn ( m , tt . input )
}
dw := NewDualWriter ( Mode1 , ls , us )
dw := NewDualWriter ( Mode1 , ls , us , p )
obj , err := dw . DeleteCollection ( context . Background ( ) , func ( ctx context . Context , obj runtime . Object ) error { return nil } , tt . input , & metainternalversion . ListOptions { } )
@ -372,7 +376,7 @@ func TestMode1_Update(t *testing.T) {
tt . setupGetFn ( m , tt . input )
}
dw := NewDualWriter ( Mode1 , ls , us )
dw := NewDualWriter ( Mode1 , ls , us , p )
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 { } )