Test that calling setValue directly (as done by remote update watchers or initial value fetch) refreshes the internal lastUpdated timestamp so that subsequent IsStale checks reflect the recent update.
(t *testing.T)
| 600 | // Test that calling setValue directly (as done by remote update watchers or initial value fetch) refreshes the |
| 601 | // internal lastUpdated timestamp so that subsequent IsStale checks reflect the recent update. |
| 602 | func TestCounterInt64_SetValueUpdatesLastUpdated(t *testing.T) { |
| 603 | counter := &counterInt64{ |
| 604 | ignoreRollbackOf: 1024, |
| 605 | registry: &sharedStateRegistry{ |
| 606 | logger: &log.Logger, |
| 607 | }, |
| 608 | } |
| 609 | |
| 610 | // Simulate a write originating from the remote sync by calling setValue directly. |
| 611 | counter.processNewValue(UpdateSourceTest, 123) |
| 612 | |
| 613 | // Immediately after the write the counter must not be considered stale for any reasonable staleness window. |
| 614 | assert.False(t, counter.IsStale(time.Second), "counter should not be stale right after setValue call") |
| 615 | |
| 616 | // After advancing the clock beyond the staleness window the value should be considered stale. |
| 617 | time.Sleep(15 * time.Millisecond) |
| 618 | assert.True(t, counter.IsStale(10*time.Millisecond), "counter should become stale once the window elapses") |
| 619 | } |
| 620 | |
| 621 | func TestCounterInt64_TryUpdate_RollbackLogic(t *testing.T) { |
| 622 | tests := []struct { |
nothing calls this directly
no test coverage detected