| 1 |
package memmetrics |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/stretchr/testify/assert" |
| 7 |
"github.com/stretchr/testify/require" |
| 8 |
"github.com/vulcand/oxy/v2/internal/holsterv4/clock" |
| 9 |
) |
| 10 |
|
| 11 |
func TestCloneExpired(t *testing.T) { |
| 12 |
clock.Freeze(clock.Date(2012, 3, 4, 5, 6, 7, 0, clock.UTC)) |
| 13 |
|
| 14 |
cnt, err := NewCounter(3, clock.Second) |
| 15 |
require.NoError(t, err) |
| 16 |
|
| 17 |
cnt.Inc(1) |
| 18 |
|
| 19 |
clock.Advance(clock.Second) |
| 20 |
cnt.Inc(1) |
| 21 |
|
| 22 |
clock.Advance(clock.Second) |
| 23 |
cnt.Inc(1) |
| 24 |
|
| 25 |
clock.Advance(clock.Second) |
| 26 |
out := cnt.Clone() |
| 27 |
|
| 28 |
assert.EqualValues(t, 2, out.Count()) |
| 29 |
} |