Skip to content

Commit

Permalink
chore: removed example blocks as they break our formatting check
Browse files Browse the repository at this point in the history
  • Loading branch information
johnabass committed May 29, 2024
1 parent a4b62b8 commit 95b41db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 33 deletions.
21 changes: 1 addition & 20 deletions clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,7 @@ type Timer interface {
// drop-in replacements for the time package.
//
// A typical use case is to establish a Clock using SystemClock() in production
// code. Test code can then alter the injected instance to a *FakeClock after the fact:
//
// type MyService struct {
// clock chronon.Clock
// }
//
// func NewMyService() *MyService {
// return &MyService{
// clock: chronon.SystemClock(),
// }
// }
//
// func TestMyService(t *testing.T) {
// s := NewMyService()
// fc := chronon.NewFakeClock()
// s.clock = fc
//
// // continue with tests, updating the fake clock to drive
// // concurrent, time-dependent code
// }
// code. Test code can then alter the injected instance to a *FakeClock after the fact.
type Clock interface {
// Now returns ths instance's notion of the current time.
Now() time.Time
Expand Down
14 changes: 1 addition & 13 deletions fakeClock.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,7 @@ func (fc *FakeClock) Add(d time.Duration) (now time.Time) {
// Set is similar to Add, except that it sets an absolute time instead
// of moving this fake clock's time by a certain delta.
//
// A common use case is to force the firing of an object by passing its When value:
//
// fc := NewFakeClock(time.Now())
// onTimer := make(chan FakeTimer)
// fc.NotifyOnTimer(onTimer)
//
// // ... spawn goroutines that run production code
//
// // this blocks until production code obtains a timer
// t := <-onTimer
//
// // force the timer to fire by updating the clock
// fc.Set(t.When())
// A common use case is to force the firing of an object by passing its When value.
func (fc *FakeClock) Set(t time.Time) {
fc.lock.Lock()
fc.now = t
Expand Down

0 comments on commit 95b41db

Please sign in to comment.