MCPcopy Create free account
hub / github.com/cortexproject/cortex / Test_WatchKey

Function Test_WatchKey

pkg/ring/kv/dynamodb/client_test.go:220–237  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

218}
219
220func Test_WatchKey(t *testing.T) {
221 ddbMock := NewDynamodbClientMock()
222 codecMock := &CodecMock{}
223 descMock := &DescMock{}
224 c := NewClientMock(ddbMock, codecMock, TestLogger{}, prometheus.NewPedanticRegistry(), 1*time.Second, defaultBackoff)
225 timesCalled := 0
226
227 ddbMock.On("Query").Return(map[string]dynamodbItem{}, nil)
228 codecMock.On("DecodeMultiKey").Return(descMock, nil)
229
230 c.WatchKey(context.TODO(), key, func(i any) bool {
231 timesCalled++
232 ddbMock.AssertNumberOfCalls(t, "Query", timesCalled)
233 codecMock.AssertNumberOfCalls(t, "DecodeMultiKey", timesCalled)
234 require.EqualValues(t, descMock, i)
235 return timesCalled < 5
236 })
237}
238
239func Test_WatchKey_UpdateStale(t *testing.T) {
240 ddbMock := NewDynamodbClientMock()

Callers

nothing calls this directly

Calls 3

NewDynamodbClientMockFunction · 0.85
NewClientMockFunction · 0.85
WatchKeyMethod · 0.65

Tested by

no test coverage detected