Skip to content
This repository was archived by the owner on May 18, 2023. It is now read-only.

Commit d13048d

Browse files
vincentbernatdjmitche
authored andcommitted
fix tests
1 parent 6e4be13 commit d13048d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

clock_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -538,24 +538,25 @@ func ExampleMock_After() {
538538
func ExampleMock_AfterFunc() {
539539
// Create a new mock clock.
540540
clock := NewMock()
541-
count := 0
541+
var count counter
542+
count.incr()
542543

543544
// Execute a function after 10 mock seconds.
544545
clock.AfterFunc(10*time.Second, func() {
545-
count = 100
546+
count.incr()
546547
})
547548
gosched()
548549

549550
// Print the starting value.
550-
fmt.Printf("%s: %d\n", clock.Now().UTC(), count)
551+
fmt.Printf("%s: %d\n", clock.Now().UTC(), count.get())
551552

552553
// Move the clock forward 10 seconds and print the new value.
553554
clock.Add(10 * time.Second)
554-
fmt.Printf("%s: %d\n", clock.Now().UTC(), count)
555+
fmt.Printf("%s: %d\n", clock.Now().UTC(), count.get())
555556

556557
// Output:
557-
// 1970-01-01 00:00:00 +0000 UTC: 0
558-
// 1970-01-01 00:00:10 +0000 UTC: 100
558+
// 1970-01-01 00:00:00 +0000 UTC: 1
559+
// 1970-01-01 00:00:10 +0000 UTC: 2
559560
}
560561

561562
func ExampleMock_Sleep() {

0 commit comments

Comments
 (0)