MCPcopy
hub / github.com/grafana/dskit / observeValueForSomeTime

Function observeValueForSomeTime

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

Source from the content-addressed store, hash-verified

131}
132
133func observeValueForSomeTime(t *testing.T, client *Client, key string, timeout time.Duration) []string {
134 t.Helper()
135
136 observed := []string(nil)
137 ctx, cancel := context.WithTimeout(context.Background(), timeout)
138 defer cancel()
139 client.WatchKey(ctx, key, func(i interface{}) bool {
140 s, ok := i.(string)
141 if !ok {
142 return false
143 }
144 t.Log("ts", time.Now(), "msg", "observed value", "val", s)
145 observed = append(observed, s)
146 return true
147 })
148 return observed
149}
150
151func TestWatchKeyWithNoStartValue(t *testing.T) {
152 c, closer := NewInMemoryClient(codec.String{}, testLogger{}, prometheus.NewPedanticRegistry())

Callers 3

TestWatchKeyNoRateLimitFunction · 0.85
TestResetFunction · 0.85

Calls 3

HelperMethod · 0.80
WatchKeyMethod · 0.65
LogMethod · 0.45

Tested by

no test coverage detected