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

Function observeValueForSomeTime

pkg/ring/kv/consul/client_test.go:211–227  ·  view source on GitHub ↗
(t *testing.T, client *Client, key string, timeout time.Duration)

Source from the content-addressed store, hash-verified

209}
210
211func observeValueForSomeTime(t *testing.T, client *Client, key string, timeout time.Duration) []string {
212 t.Helper()
213
214 observed := []string(nil)
215 ctx, cancel := context.WithTimeout(context.Background(), timeout)
216 defer cancel()
217 client.WatchKey(ctx, key, func(i any) bool {
218 s, ok := i.(string)
219 if !ok {
220 return false
221 }
222 t.Log("ts", time.Now(), "msg", "observed value", "val", s)
223 observed = append(observed, s)
224 return true
225 })
226 return observed
227}
228
229func TestWatchKeyWithNoStartValue(t *testing.T) {
230 c, closer := NewInMemoryClient(codec.String{}, testLogger{}, prometheus.NewPedanticRegistry())

Callers 3

TestWatchKeyNoRateLimitFunction · 0.85
TestResetFunction · 0.85

Calls 2

WatchKeyMethod · 0.65
LogMethod · 0.45

Tested by

no test coverage detected