MCPcopy
hub / github.com/kubernetes/client-go / TestReplaceCallsPush

Function TestReplaceCallsPush

tools/cache/undelta_store_test.go:107–131  ·  tools/cache/undelta_store_test.go::TestReplaceCallsPush
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestReplaceCallsPush(t *testing.T) {
108 mkObj := func(name string, val interface{}) testUndeltaObject {
109 return testUndeltaObject{name: name, val: val}
110 }
111
112 var got []interface{}
113 var callcount int = 0
114 push := func(m []interface{}) {
115 callcount++
116 got = m
117 }
118
119 u := NewUndeltaStore(push, testUndeltaKeyFunc)
120
121 m := []interface{}{mkObj("a", 1)}
122
123 u.Replace(m, "0")
124 if callcount != 1 {
125 t.Errorf("Expected 1 calls, got %d", callcount)
126 }
127 expected := []interface{}{mkObj("a", 1)}
128 if !reflect.DeepEqual(expected, got) {
129 t.Errorf("Expected %#v, Got %#v", expected, got)
130 }
131}

Callers

nothing calls this directly

Calls 3

ReplaceMethod · 0.95
NewUndeltaStoreFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected