@@ -4,8 +4,10 @@ import (
44 "testing"
55 "time"
66
7- "github.com/godogx/clocksteps"
87 "github.com/stretchr/testify/assert"
8+ "github.com/stretchr/testify/require"
9+
10+ "github.com/godogx/clocksteps"
911)
1012
1113func TestClock (t * testing.T ) {
@@ -18,8 +20,8 @@ func TestClock(t *testing.T) {
1820 assert .True (t , now .Before (c .Now ()))
1921
2022 // Errors while adding time to a live clock.
21- assert . Equal (t , clocksteps . ErrClockIsNotSet , c .Add (time .Hour ))
22- assert . Equal (t , clocksteps . ErrClockIsNotSet , c .AddDate (0 , 0 , 1 ))
23+ require . ErrorIs (t , c .Add (time .Hour ), clocksteps . ErrClockIsNotSet )
24+ require . ErrorIs (t , c .AddDate (0 , 0 , 1 ), clocksteps . ErrClockIsNotSet )
2325
2426 // Freeze the clock.
2527 c .Freeze ()
@@ -42,7 +44,7 @@ func TestClock(t *testing.T) {
4244 // Change the time.
4345 ts = ts .Add (2 * time .Hour )
4446 err := c .Add (2 * time .Hour )
45- assert .NoError (t , err )
47+ require .NoError (t , err )
4648
4749 <- time .After (50 * time .Millisecond )
4850
@@ -51,12 +53,23 @@ func TestClock(t *testing.T) {
5153 // Change the date.
5254 ts = ts .AddDate (2 , 1 , 3 )
5355 err = c .AddDate (2 , 1 , 3 )
54- assert .NoError (t , err )
56+ require .NoError (t , err )
5557
5658 <- time .After (50 * time .Millisecond )
5759
5860 assert .Equal (t , ts , c .Now ())
5961
62+ // Add more timestamps.
63+ ts2 := time .Date (2021 , 2 , 3 , 4 , 5 , 6 , 0 , time .UTC )
64+ c .Next (ts2 )
65+
66+ oldTs := c .Now ()
67+
68+ assert .Equal (t , ts , oldTs )
69+ assert .NotEqual (t , ts2 , oldTs )
70+ assert .Equal (t , ts2 , c .Now ())
71+ assert .Equal (t , ts2 , c .Now ())
72+
6073 // Unfreeze the clock.
6174 c .Unfreeze ()
6275
0 commit comments