(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestLeaveOnStoppingDelegate(t *testing.T) { |
| 20 | onStoppingCalled := false |
| 21 | |
| 22 | ctx := context.Background() |
| 23 | cfg := prepareBasicLifecyclerConfig() |
| 24 | |
| 25 | testDelegate := &mockDelegate{ |
| 26 | onStopping: func(l *BasicLifecycler) { |
| 27 | assert.Equal(t, LEAVING, l.GetState()) |
| 28 | onStoppingCalled = true |
| 29 | }, |
| 30 | } |
| 31 | |
| 32 | leaveDelegate := NewLeaveOnStoppingDelegate(testDelegate, log.NewNopLogger()) |
| 33 | lifecycler, _, err := prepareBasicLifecyclerWithDelegate(t, cfg, leaveDelegate) |
| 34 | require.NoError(t, err) |
| 35 | require.NoError(t, services.StartAndAwaitRunning(ctx, lifecycler)) |
| 36 | |
| 37 | assert.NoError(t, services.StopAndAwaitTerminated(ctx, lifecycler)) |
| 38 | assert.True(t, onStoppingCalled) |
| 39 | } |
| 40 | |
| 41 | func TestTokensPersistencyDelegate_ShouldSkipTokensLoadingIfFileDoesNotExist(t *testing.T) { |
| 42 | // Create a temporary file and immediately delete it. |
nothing calls this directly
no test coverage detected