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

Function TestWaitInstanceState_TimeoutOnError

ring/util_test.go:394–412  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

392}
393
394func TestWaitInstanceState_TimeoutOnError(t *testing.T) {
395 t.Parallel()
396
397 const (
398 instanceID = "test"
399 timeoutDuration = time.Second
400 )
401
402 ctx, cancel := context.WithTimeout(context.Background(), timeoutDuration)
403 defer cancel()
404
405 ring := &RingMock{}
406 ring.On("GetInstanceState", mock.Anything, mock.Anything).Return(PENDING, errors.New("instance not found in the ring"))
407
408 err := WaitInstanceState(ctx, ring, instanceID, ACTIVE)
409
410 assert.Equal(t, context.DeadlineExceeded, err)
411 ring.AssertCalled(t, "GetInstanceState", instanceID)
412}
413
414func TestWaitInstanceState_ExitsAfterActualStateEqualsState(t *testing.T) {
415 t.Parallel()

Callers

nothing calls this directly

Calls 2

WaitInstanceStateFunction · 0.85
EqualMethod · 0.45

Tested by

no test coverage detected