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

Function Test_WatchKey_UpdateStale

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

Source from the content-addressed store, hash-verified

237}
238
239func Test_WatchKey_UpdateStale(t *testing.T) {
240 ddbMock := NewDynamodbClientMock()
241 codecMock := &CodecMock{}
242 c := NewClientMock(ddbMock, codecMock, TestLogger{}, prometheus.NewPedanticRegistry(), defaultPullTime, defaultBackoff)
243 staleData := &DescMock{}
244
245 ddbMock.On("Query").Return(map[string]dynamodbItem{}, nil).Once()
246 codecMock.On("DecodeMultiKey").Return(staleData, nil)
247
248 c.WatchKey(context.TODO(), key, func(i any) bool {
249 ddbMock.AssertNumberOfCalls(t, "Query", 1)
250 codecMock.AssertNumberOfCalls(t, "DecodeMultiKey", 1)
251 require.EqualValues(t, staleData, i)
252 return false
253 })
254
255 ddbMock.On("Query").Return(map[string]dynamodbItem{}, errors.Errorf("failed"))
256 staleData.On("Clone").Return(staleData).Once()
257
258 c.WatchKey(context.TODO(), key, func(i any) bool {
259 ddbMock.AssertNumberOfCalls(t, "Query", 12)
260 codecMock.AssertNumberOfCalls(t, "DecodeMultiKey", 1)
261 require.EqualValues(t, staleData, i)
262 return false
263 })
264}
265
266func Test_WatchKey_AlwaysRetry(t *testing.T) {
267 casBackoffConfig := backoff.Config{

Callers

nothing calls this directly

Calls 3

NewDynamodbClientMockFunction · 0.85
NewClientMockFunction · 0.85
WatchKeyMethod · 0.65

Tested by

no test coverage detected